943,407 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
May 28th, 2003
0

Playing .Wav/MIDI files in a Visual Basic Program

Expand Post »
I cannot figure out how you go about playing a Wav/MIDI file in a VB Program. I found one thing but it didn't work. This is a little old but the version is Visual Basic 4.0. It actually runs on Windows XP!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gemini2011 is offline Offline
1 posts
since May 2003
Jun 11th, 2003
0
Re: Playing .Wav/MIDI files in a Visual Basic Program
What did you find? What you found DOES work but only in VB4? Are you looking for something for VB.NET ?
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Apr 8th, 2004
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

i want to build database application in vb.net so how can i build it
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KrunalPatel is offline Offline
1 posts
since Apr 2004
Apr 28th, 2004
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

try using the sndPlaySound API
Reputation Points: 19
Solved Threads: 0
Light Poster
BlackDice is offline Offline
43 posts
since Apr 2004
May 3rd, 2004
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

Quote originally posted by bdiamond ...
try using the sndPlaySound API
bdiamond, any chance you could use sndPlaySound in a code snippet? I'm not sure how to employ it. thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Stooge is offline Offline
1 posts
since May 2004
May 4th, 2004
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

here's a module I used to play sounds. I don't remember how I did it with just the .wav fiile, but I THINK you can just put the name of the file in place of loadresdata. But in this example I have my .wav files saved in my resource file with id's of 101 and 102. If your app is always going to use the same set of sounds, I think this is the easiest way, and quicker. So to play the sound I just call MySounds(101) and it plays that file. Here's the snippet from a module:

Option Explicit
Public Declare Function sndPlaySound Lib _
"winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_ASYNC = &H1
Public Const SND_MEMORY = &H4
Public Sub MySounds(intSound As Integer)
'101 is drums sound used for startup
'102 is bop sound used for going from form to form
sndPlaySound StrConv(LoadResData(intSound, "custom"), vbUnicode) _
, SND_ASYNC Or SND_MEMORY
DoEvents
End Sub


Quote originally posted by Stooge ...
bdiamond, any chance you could use sndPlaySound in a code snippet? I'm not sure how to employ it. thanks.
Reputation Points: 19
Solved Threads: 0
Light Poster
BlackDice is offline Offline
43 posts
since Apr 2004
Jun 3rd, 2005
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

Hi I am extreamly new to all forms of programming... I need a little help figuring out where to put all of the dim statements... I tried the code but the evil gremlins in my computer are giving me error messages... :rolleyes:
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Spartan117 is offline Offline
1 posts
since Jun 2005
Jun 4th, 2005
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

I see this is your first post, So, Welcome To Daniweb, and I hope you enjoy the site. One favor I am going to have to ask you, right off the bat, is not to piggy or resurrect ancient threads. This thread has been dead for a year, and it's best (and proper) to start your own thread if you have a question. Thanx, and I hope to be able to be of assistance to you.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Aug 13th, 2008
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

Dear Spartan,
Having the same trouble trying to get vb.net 2005 to run midi files. I was referred to this link http://forums.msdn.microsoft.com/zh-...-b6ffab8596e8/

this forum might help you.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Water-Orb is offline Offline
2 posts
since Aug 2008
Jun 12th, 2009
0

Re: Playing .Wav/MIDI files in a Visual Basic Program

For VB4 ( Visual Basic 4 ) VB4.0 ( Visual Basic 4.0 )
To play a sound the easiest and quickest way:

THIS WORKS!

Shell ("sndrec32" & " /play /close " & Text1.Text)
Replace Text1.Text with whatever your using to play a sound.

This will open sound-recorder of built into windows and play the sound then close the player once it is done.

This works, this is what I use. There may be a switch to make it stay invisible.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
guest2425 is offline Offline
1 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: ctrl question...
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: whats wrong here???





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC