Computing.Net > Forums > Programming > Wave files in VB6

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Wave files in VB6

Reply to Message Icon

Name: BaBa
Date: December 27, 2002 at 21:16:51 Pacific
OS: Win98
CPU/Ram: 98M
Comment:

Hi,

I would like to know if there is a way to compare two wave files in VB6?

If Wave1=Wave2 then
Do this
else
Do that
end if

The above code is not VB6. It is a repesentation of what I want to do.
please help.
anything is appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: HiJinx
Date: December 27, 2002 at 23:25:15 Pacific
Reply:

What does "equal" mean? Same name? Same size? Same content? If you mean content, then I don't think you can pull it off with a simple 'if' statement. You'd probably have to open the files and compare them piece by piece. I quickly wrote the following code, but it's kinda pokey (may not be a problem if your file sizes are small... or maybe someone else will post a simpler, more efficient solution.) I'm leaving in the hard-coded file names... just replace them with whatever variables you're using. I tested it with .mp3's but it should work just as well with .wav's.

Private Sub Command1_Click()

Dim intFile1 As Integer
Dim intFile2 As Integer
Dim strBuff1 As String
Dim strBuff2 As String
Dim flgEqual As Boolean


flgEqual = True

intFile1 = FreeFile
Open "c:\piano1.mp3" For Binary As intFile1
intFile2 = FreeFile
Open "c:\piano2.mp3" For Binary As intFile2

Do While Not EOF(intFile1)

Line Input #intFile1, strBuff1
Line Input #intFile2, strBuff2

If strBuff1 strBuff2 Then
flgEqual = False
Exit Do
End If

Loop

If flgEqual = True Then
MsgBox "They're the same."
Else
MsgBox "They're different."
End If

Close #intFile1
Close #intFile2

End Sub


0

Response Number 2
Name: HiJinx
Date: December 27, 2002 at 23:29:01 Pacific
Reply:

Replace

If strBuff1 strBuff2 Then

with...

If strBuff1 [Not Equal] strBuff2 Then

The VB sign for Not Equal is a less-than sign immediately followed by a greater-than sign. (I tried using the HTML code for less-than, and it previewed ok, but still got stripped in the final post.)


0

Response Number 3
Name: hukre
Date: December 28, 2002 at 18:50:58 Pacific
Reply:

Is it not possible to use fc.exe which is supplied with DOS and compares two files bit by bit, and call it up from VB6?


0

Response Number 4
Name: hukre
Date: December 28, 2002 at 20:04:58 Pacific
Reply:

Have a look at www.serverwatch.com/tutorials/article.php/1475411


0

Response Number 5
Name: BaBa
Date: December 28, 2002 at 21:49:58 Pacific
Reply:

HiJinx,

I thank you very, very much.
Sorry for the misunderstanding! Yes, I meant to compare the contents of the files not the size.

Your response looks great. I haven't tried it yet; however I will give it a try soon. I will make sure I let you know if it works.

I thought that I was trying something impossible.

Suppose that both wave files have the same content, but they don't have the same size.
Would the above trick still pull it off?

Hukre,

I thank you for you responses as well.
I will take a look at your reference right after this post.

Once again, thanks to both of you guys!



0

Related Posts

See More



Response Number 6
Name: HiJinx
Date: December 28, 2002 at 22:17:22 Pacific
Reply:

Well... from the computer's precise point of view, two files can't have the same content, but be of different sizes. I'm pretty sure I know what you're getting at though, and let's just say that the analysis required would be a wee bit more sophistocated than I offered :). My code doesn't take into account any small diferences which may exist between two files which may be otherwise pretty much the same.

What you want is possible, but it's more than I'd be capable of helping you with.


0

Sponsored Link
Ads by Google
Reply to Message Icon

vb: merge and save obj an... VC++ DLL accessing MS ACC...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Wave files in VB6

Wave files in VB6 www.computing.net/answers/programming/wave-files-in-vb6/5131.html

How To Read/Write File in VB6 www.computing.net/answers/programming/how-to-readwrite-file-in-vb6/7105.html

concatenating wave files in VB www.computing.net/answers/programming/concatenating-wave-files-in-vb/6272.html