please help me on my problem about visual basic 6.0
my problem is how to add music background ....
please give me some code or some idea thank you....

7 Years
Discussion Span
Last Post by AndreRet

You can use an API function to play your file....

try to use sndPlaySound function...The computer i'm using has no VB6 installed so I just search the internet...for more details: this link might be useful to you...


NOTE: files must in .WAV format....

Example: copy and paste this in a form with 1 command button named Command1

Option Explicit

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Const SND_ASYNC = &H1
Private Const SND_LOOP = &H8
Private Const SND_NODEFAULT = &H2
Private Const SND_SYNC = &H0
Private Const SND_NOSTOP = &H10
Private Const SND_MEMORY = &H4

Private Sub Command1_Click()
    sndPlaySound App.Path & "\ButtonClick.wav", SND_ASYNC or SND_LOOP
End Sub

For background music, midi, rmi, and such, have a look at the MMC (Microsoft Multimedia Control) then you can still play sound effects in wav format using sndPlaySound API over the background music and yes, I do mean at the same time...

Good Luck


thank you for help me... but i want background music like mp3.....
pleasss help me again at second time and give me again codes or idea...


You can use your media player as well if you do not want to get involved in API's. Set a reference to the mediaplayer library files, select it from components and then load the mp3 files to be played. Set the mediaplayer's visibility to false.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.