Wednesday, September 24 2003 PM when an event is completed, the program sends a specific signal to add the user interface features of the program, such as when the download is completed or a command is selected. Using a multimedia function and using a vbprogram to run WAV files is a breeze. However, the system must install a sound card for this operation.
The API function you need is called PlaySound. The following is the declaration of this function:
Public Declare Function PlaySound Lib "winmm. dll "_
Alias "PlaySoundA" (ByVallpszName As String ,_
ByValhModule As Long, ByValdwFlags As Long )_
As Long
In this function, the first variable is the name, including the path of the running Wave file. The second variable is usually not used when running the file, so you can assign it to zero. The last variable contains a tag that controls how a function works.
For the current needs, two tags are required. They are:
SND_ASYNC (value = 1): runs in asynchronous mode, which means that the function is running when the sound is played.
SND_FILENAME (value = & H20000): The first variable is a file name.
The following code marks the sound in the dingdong.wav file:
PlaySound "dingdong.wav", CLng (0 ),_
SND_ASYNC Or SND_FILENAME
When running audio files in a program, there are two other points worth noting. First, you must ensure that a specific audio file exists. Otherwise, an error may occur. This process can be completed using a simple function:
Public Function FileExists (FullFileName) As Boolean
'Passed a filename (with path) returns
'True if the file exists, False if not.
Dim s
S = dir (FullFileName)
If s = "" Then
FileExists = False
Else
FileExists = True
End If
End Function
Second, the program must provide users with the option to turn off the sound. This process can be achieved by using a global Boolean variable such as gProgramSoundsEnabled.