944,029 Members | Top Members by Rank

Ad:
Jul 11th, 2007
0

how to insert sound in vb6 programming

Expand Post »
please help me how to make a background music in vb6.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paodzy is offline Offline
17 posts
since Jun 2007
Jul 14th, 2007
0

Re: how to insert sound in vb6 programming

Hi, you can use this code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'First add the ActiveX MMControl
  2.  
  3. Option Explicit
  4.  
  5. Private Sub Form_Load()
  6.  
  7. Dim AppPath As String
  8.  
  9. 'Appointment of music file from within your program
  10.  
  11. If Right$(App.Path, 1) <> "\" Then
  12. AppPath = App.Path & "\Sound.wav"
  13. Else
  14. AppPath = App.Path & "Sound.wav"
  15. End If
  16.  
  17. 'Determine the type of music file
  18.  
  19. MMControl1.DeviceType = "waveaudio"
  20.  
  21. 'If the file type " MIDI "
  22. 'MMControl1.DeviceType = "Sequencer"
  23.  
  24. 'Determining file name
  25.  
  26. MMControl1.FileName = AppPath
  27. 'Opening the file
  28.  
  29. MMControl1.Command = "open"
  30. 'Reading file
  31.  
  32. MMControl1.Command = "play"
  33.  
  34. End Sub
  35.  
  36.  
  37. Private Sub MMControl1_Done(NotifyCode As Integer)
  38.  
  39. 'This event at the end of passage voice
  40.  
  41. 'Re-reading passage voice
  42. MMControl1.Command = "prev"
  43. 'Reading passage voice again
  44. MMControl1.Command = "play"
  45.  
  46. End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Naseem89 is offline Offline
12 posts
since Jul 2007
Jul 16th, 2007
0

Re: how to insert sound in vb6 programming

hi !!! could you tell me how to make this code point to exactly where the file located , for i.e, D:\...\sound.wav

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. AppPath = App.Path & "\Sound.wav"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smiles is offline Offline
21 posts
since Jun 2007
Jul 16th, 2007
0

Re: how to insert sound in vb6 programming

In the code by myself placing the music file is in the same folder that contains your program.
E.g:

If your program in this directory:- "D : \ My Project \ test.exe \", it must be the music file in the following directory :- "D : \ My Project \ song.wav"

I hope that this is clear.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Naseem89 is offline Offline
12 posts
since Jul 2007
Jul 16th, 2007
0

Re: how to insert sound in vb6 programming

The inter ( app.path ) it means:

The music file, or any other file must be in the same program directory
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Naseem89 is offline Offline
12 posts
since Jul 2007
Jul 17th, 2007
0

Re: how to insert sound in vb6 programming

You can directly use the API PlaySound to do that .
No need to write all that code.
Last edited by debasisdas; Jul 17th, 2007 at 9:20 am.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007

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: generating one report from multiple tables
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: vb and access





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


Follow us on Twitter


© 2011 DaniWeb® LLC