I'm sorry this is a very simple question but i have just forgotten... How do you get a sound to play when you clik on a button or image? Thanks...
Bye Bye... XXX...
http://www.c-interactive.co.uk
Printable View
I'm sorry this is a very simple question but i have just forgotten... How do you get a sound to play when you clik on a button or image? Thanks...
Bye Bye... XXX...
http://www.c-interactive.co.uk
There are lots of different sounds. If you want a simple beep, try this one:
If you want to play a wave, try this:Code:Beep
(in a module)
(in the form)Code:Public Declare Function sndPlaySound& lib "winmm.dll" Alias
"sndPlaySoundA" (byval lpszSoundName as string, byval
uFlags as long)
'WAV Sound values
Global Const SND_SYNC = &H0
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Global Const SND_LOOP = &H8
Global Const SND_NOSTOP = &H10
If you want to play a note at any frequency for any duration, try this:Code:Dim wFlags%
Dim x%
Dim tmpSoundName As String
tmpSoundName = "c:\windows\chimes.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(tmpSoundName, wFlags%)
note: you need to get win95io.dll from http://www.lvr.com/parport.htm
In the form, put a two command buttons and a horizontal scroll bar. Command1 is Stop, and command two is Go. The scroll bar changes the frequency, and is limited to above 37. The code:
hope this helps,Code:Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
Private Sub Sounds(Freq)
Dim LoByte As Integer
Dim HiByte As Integer
Dim Clicks As Integer
Dim SpkrOn As Integer
Clicks = CInt(1193280 / Freq)
LoByte = Clicks And &HFF
HiByte = Clicks \ 256
vbOut 67, 182
vbOut 66, LoByte
vbOut 66, HiByte
SpkrOn = vbInp(97) Or &H3
vbOut 97, SpkrOn
End Sub
Private Sub Command1_Click()
vbOut 97, 0
End Sub
Private Sub Command2_Click()
Freq = HScroll1.Value
Sounds Freq
End Sub
Private Sub HScroll1_Change()
Freq = HScroll1.Value
Sounds Freq
End Sub
Private Sub HScroll1_Scroll()
Freq = HScroll1.Value
Sounds Freq
End Sub
bob
Thank you so much. It's the sencond option i needed. Thankyou.