Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-01-2008, 04:15 AM   #1 (permalink)
ludask
Recruit
 
Join Date: May 2008
Posts: 3
ludask is on a distinguished road
design form help with vb2005

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
ludask is offline   Reply With Quote
Old 05-01-2008, 04:53 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
Sorry, your code is a function, which compare two files byte by byte, it isn't doing any form alteration, so it would be impossible to display it as a screenshot.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
generic form mailer metazai PHP 10 03-10-2008 08:43 AM
Form questions JDE HTML, XML, Javascript, AJAX 2 10-29-2005 01:52 AM
Child Form to Parent Form WmFenn MS Technologies ( ASP, VB, C#, .NET ) 2 07-20-2005 08:10 AM
Passing Values from Popup Form to Main Form chrislopezz PHP 7 03-28-2005 12:45 PM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM


All times are GMT -8. The time now is 07:24 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting