hi,
i have a code im trying to understand but its hard for me to without how the form looks like? can someone make a form how the code i provide?screenshot it that would be fine.
im not sure where would you implement this code to? i was thinkin to the button command name under Compare? but i cant get it working?
thanks
code:
Private Function CompareFiles(ByVal filePathOne As String, ByVal filePathTwo As String) As Boolean
Dim fileOneByte As Integer
Dim fileTwoByte As Integer
Dim fileOneStream As FileStream
Dim fileTwoStream As FileStream
' If user has selected the same file as file one and file two....
If (filePathOne = filePathTwo) Then
' Files are the same.
Me.ResultsRichTextBox.Text = "Files are the same; file one is file two."
Return True
End If
' Open a FileStream for each file.
fileOneStream = New FileStream(filePathOne, FileMode.Open)
fileTwoStream = New FileStream(filePathTwo, FileMode.Open)
' If the files are not the same length...
If (fileOneStream.Length <> fileTwoStream.Length) Then
fileOneStream.Close()
fileTwoStream.Close()
' File's are not equal.
Me.ResultsRichTextBox.Text = "Files are not the same length; they are not equal."
Return False
End If
Dim areFilesEqual As Boolean = True
' Loop through bytes in the files until
' a byte in file one <> a byte in file two
' OR
' end of the file one is reached.
Do
' Read one byte from each file.
fileOneByte = fileOneStream.ReadByte()
fileTwoByte = fileTwoStream.ReadByte()
If fileOneByte <> fileTwoByte Then
' Files are not equal; byte in file one <> byte in file two.
Me.ResultsRichTextBox.Text = "Files are not equal; contents are different."
areFilesEqual = False
Exit Do
End If
Loop While (fileOneByte <> -1)
' Close the FileStreams.
fileOneStream.Close()
fileTwoStream.Close()
Return areFilesEqual
End Function
design form help with vb2005
Started by kenneth_888, May 01 2008 04:17 AM
1 reply to this topic
#1
Posted 01 May 2008 - 04:17 AM
|
|
|
#2
Posted 02 May 2008 - 08:16 AM
You need a few objects:
1. A button that says "Compare".
2. Two text boxes, with "Browse..." buttons next to each.
3. An OpenFileDialog control, to let the user select the files.
It doesn't really matter how you organise it - just make it clear and simple to understand.
1. A button that says "Compare".
2. Two text boxes, with "Browse..." buttons next to each.
3. An OpenFileDialog control, to let the user select the files.
It doesn't really matter how you organise it - just make it clear and simple to understand.


Sign In
Create Account

Back to top









