With resource files, you can play a sound file (WAV file) directly in the EXE file to make the program more professional.
(1) Launch VB6.0, load "Visual Basic 6 Resource Editor" in "Add Procedure → Add Program Manager"
(2) In the VB Resource Editor window, click "Add Custom Data", add any WAV file, and double-click the custom resource you just created, pop up the Edit Properties window, defined as follows:
Type: "Wave"
Identification number: 102
Language: Chinese (China)
(3) Save the resource file, write the following code:
Option expedition
Private Declare Function SndplaySoundFromMemory Lib "Winmm.dll" Alias "SndPlaySounda" (LPSZSOUNDA AS ANY, BYVAL UFLAGS AS Long) AS Long
PRIVATE SND_ASYNC = & H1 &
PRIVATECONST SND_MEMORY = & H4 &
DIM Barr () as Byte
Private sub flow_load ()
Barr = loadingResdata (101, "Custom") 'It is best not to put this sentence in the button clicks, because this will make the playback sound is sluggish
End Sub
Private submmand1_click ()
SNDPLAYSOUNDFROMMORY BARR (0), SND_ASYNC OR SND_MEMORY
End Sub