how can I change the beep sound? that is, suppose I have a code like this:
and I want to change the sound of beeping to another wav file, what should I do? thanks!!Code:sub command1_click()
beep
end sub
Printable View
how can I change the beep sound? that is, suppose I have a code like this:
and I want to change the sound of beeping to another wav file, what should I do? thanks!!Code:sub command1_click()
beep
end sub
Use PlaySound API will do.
Code:Option Explicit "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_SYNC = &H0 ' Play synchronously (default).
Private Const SND_ASYNC = &H1 ' Play asynchronously (see note below).
Private Const SND_NODEFAULT = &H2 ' Do not use default sound.
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file.
Private Const SND_LOOP = &H8 ' Loop the sound until next sndPlaySound.
Private Const SND_NOSTOP = &H10 ' Do not stop any currently playing sound.
Private Sub Form_Load()
PlaySound "C:\welcome.wav", 0&, SND_ASYNC Or SND_NODEFAULT
End Sub
Use the Beep API:
This will sound an 800 Hz tone for 1 sec.
Code:Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Sub Form_Load()
Beep 800, 1000
End Sub
CyberCarsten, Beep API ony work for WinNT or Win2K platform :)
Chris, you are absolutely right! :)
I tried it on Win2k: Worked fin!
Then I tried it on: Win98: PLING!!! (Didn't work! :) )