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....

Recommended Answers

All 4 Replies

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...

http://blog.codebeach.com/2008/02/playing-wav-sound-files-in-visual-basic.html

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.