|
#1
|
|||
|
|||
|
No Beep or any sound from VB code
I have the Beep API
I have put: Beep on a line in my code I have copied others Beep code I have copied other similiar sound codes My PC internal speaker wires connected My sound card functions for CDs, etc. No sounds can be generated from VB6 |
|
#2
|
||||
|
||||
|
If you go to "Start", "Control Panel", "Sounds...", then select the "Sounds" tab and select "Critical Stop", then click on the ">" button, do you hear the sound?
__________________
Bob Rouse Comsquared, Inc. |
|
#3
|
|||
|
|||
|
'Critical Stop" does not create a sound.
|
|
#4
|
|||
|
|||
|
I created a small vb6 program as follows
Private Sub Form_Load() Dim loopvar As Integer Dim response As Integer For loopvar = 1 To 1 Beep Next loopvar response = MsgBox("Did you hear the beeps", vbOKOnly, "Beeps") For loopvar = 1 To 5 Beep Next loopvar response = MsgBox("Did you hear the beeps", vbOKOnly, "Beeps") For loopvar = 1 To 10 Beep Next loopvar response = MsgBox("Did you hear the beeps", vbOKOnly, "Beeps") End Sub I got one beep before each message box appeared. I then went to the control pannel > sounds > sounds tab > clicked on default beep and determined that was the sound that sounded when I ran the vb program. You might want to see if the default beep is checked and see what wav the pc is using for that sound. I found that when I changed the wav for the default beep from Windows XP ding wav to the ding wav the sound was louder. You might try some experimenting. Jerry Nesbett
__________________
Jerry Nesbett |
|
#5
|
||||
|
||||
|
If the sound is not working for "Critical Stop", then Beep() will not work. You will need to resolve that issue first.
__________________
Bob Rouse Comsquared, Inc. |
|
#6
|
|||
|
|||
|
Do all your sounds have speakers to the left of them? (in the control panel) If they don't then click browse and set some sounds from the windows directory. If they do, go to windows media player or another media player and try to play a song. If you don't hear it, check your sound card or look for a sound card driver on Download.com or other web sites. If you hear it, make sure the sounds set are working and are not corrupt. Make sure that your speakers are pluged into the computer all the way and that they are in the right spot. Make sure your speakers are on and the volumes are up including the computer's output volume (can be set in the task tray or in the control panel) Your speakers may be broken.
|
|
#7
|
|||
|
|||
|
I can now click a sound in the "Sounds and Audio Device Properties" and I hear the sound.
There are catagories for: Windows, Net meetings, Windows Explorer, MS Developer & Windows Messenger. There is no catagory for VB. Do I need to have VB as an event catagory on this list and if so how do I get it there? In Browse, I found tada.wav which is one of the sounds that I failed to hear in my VB, but there was nothing listed as a beep.wav. I searched the computer and did not find beep.wav. Jerry's comment implied that the ding.wav might be the sound that VB uses for the Beep. If so how do I make the Beep API use that or make VB initiate sounds? Thanks, Winnie_the_Pough Last edited by dmb-job; 03-30-2005 at 11:48 PM. |
|
#8
|
||||
|
||||
|
I believe "beep()" plays the sound assigned to "Critical Stop", but it may be one of the others. You may have to experiment a bit. There is no "beep.wav"
__________________
Bob Rouse Comsquared, Inc. |
|
#9
|
|||
|
|||
|
actually Default Beep is played.
|
|
#10
|
|||
|
|||
|
You can use BEEP on a line by itself with no API, or use the API for something other than the default beep.
Sound Module: Code:
Option Explicit Public SoundFile() As String Sub LoadSounds() ReDim SoundFile(0) As String SoundFile(0) = "C:\WINDOWS\MEDIA\TADA.WAV" End Sub Code:
Option Explicit
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Dim flag As Boolean
Private Sub Command1_Click()
If Not flag Then
Command1.Caption = "Stop"
PlaySound SoundFile(0), ByVal 0&, SND_ASYNC Or SND_LOOP
Else
Command1.Caption = "Play"
PlaySound SoundFile(0), ByVal 0&, SND_MEMORY
End If
flag = Not flag
End Sub
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Call LoadSounds
Command1.Caption = "Play"
End Sub
__________________
David CodeGuru Article: Bound Controls are Evil-VB6 CodeGuru Reviewer 2006 Dell CSP 2006, 2007 & 2008 MVP Visual Basic If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
|
|
#11
|
||||
|
||||
|
Quote:
EDIT: I forgot to mention that prior to messing with it this XP machine was using 'Windows XP Ding.wav' as the 'Default Beep'. Last edited by CDRIVE; 06-08-2008 at 12:30 AM. |
|
#12
|
|||
|
|||
|
Thanks, I will give it a try. Looks like this fills some of my missing education. I am self taught on VB6.
"Good Software like Good Food Takes Time to Prepare" Winnie-the-Pough |
|
#13
|
||||
|
||||
|
Quote:
Code:
Option Explicit
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Sub Command1_Click()
Beep (800, 500)
End Sub
Code:
Private Sub Command2_Click()
Dim Morse%
Dim Dit%
Dim Dah%
' Beep 800, 100 'Beep Freq = 800Hertz. Duration = 100mS
Morse = 800 'Frequency (Hertz)
Dit = 100 'Duration (100mS)
Dah = 300 'Duration (300mS)
Beep Morse, Dit
Pause 0.05
Beep Morse, Dah
Pause 0.05
Beep Morse, Dah
Pause 0.2
Beep Morse, Dit
Pause 0.05
Beep Morse, Dah
Pause 0.2
Beep Morse, Dit
Pause 0.05
Beep Morse, Dit
Pause 0.05
Beep Morse, Dah
Pause 0.05
Beep Morse, Dah
Pause 0.05
Beep Morse, Dah
Pause 0.2
Beep Morse, Dit
Pause 0.2
Beep Morse, Dit
Pause 0.05
Beep Morse, Dah
Pause 0.05
Beep Morse, Dit
Pause 0.2
Beep Morse, Dah
Pause 0.05
Beep Morse, Dah
Pause 0.05
Beep Morse, Dit
Pause 0.05
Beep Morse, Dah
End Sub
Private Sub Pause(ByVal Delay As Double)
Dim x As Double
x = Timer + Delay
Do While x > Timer
DoEvents
Loop
End Sub
|
|
#14
|
|||
|
|||
|
Many Thanks to all you friends:
I have never used MM control. You just sent me off to investigate Pause Click, Enabled, PauseVisible,.... Except for sounds, I don't have any interest in MM. But this forced me to at least look. I write Client side software using VB6 WebBrowser. "Good Software like Good Food Takes Time to Prepare" Winnie-the-Pough |
|
#15
|
||||
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|