Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 03-29-2005, 03:49 PM
dmb-job dmb-job is offline
Registered User
 
Join Date: Jul 2004
Location: St. Louis, Mo
Posts: 111
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
Reply With Quote
  #2  
Old 03-29-2005, 04:56 PM
brouse's Avatar
brouse brouse is offline
Registered User
 
Join Date: Jan 2004
Location: Atlanta, GA
Posts: 388
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.
Reply With Quote
  #3  
Old 03-30-2005, 02:51 AM
dmb-job dmb-job is offline
Registered User
 
Join Date: Jul 2004
Location: St. Louis, Mo
Posts: 111
'Critical Stop" does not create a sound.
Reply With Quote
  #4  
Old 03-30-2005, 09:07 AM
jnesbett jnesbett is offline
Registered User
 
Join Date: Jan 2004
Location: Minneapolis, Minnesota
Posts: 36
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
Reply With Quote
  #5  
Old 03-30-2005, 10:55 AM
brouse's Avatar
brouse brouse is offline
Registered User
 
Join Date: Jan 2004
Location: Atlanta, GA
Posts: 388
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.
Reply With Quote
  #6  
Old 03-30-2005, 11:47 AM
ryanc05 ryanc05 is offline
Registered User
 
Join Date: Mar 2005
Posts: 5
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.
Reply With Quote
  #7  
Old 03-30-2005, 11:46 PM
dmb-job dmb-job is offline
Registered User
 
Join Date: Jul 2004
Location: St. Louis, Mo
Posts: 111
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.
Reply With Quote
  #8  
Old 04-01-2005, 06:32 PM
brouse's Avatar
brouse brouse is offline
Registered User
 
Join Date: Jan 2004
Location: Atlanta, GA
Posts: 388
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.
Reply With Quote
  #9  
Old 06-06-2008, 05:34 AM
adamrlee adamrlee is offline
Registered User
 
Join Date: Jun 2008
Posts: 3
actually Default Beep is played.
Reply With Quote
  #10  
Old 06-06-2008, 11:19 PM
dglienna dglienna is offline
Registered User
 
Join Date: May 2008
Location: Chicago, IL
Posts: 64
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!
Reply With Quote
  #11  
Old 06-08-2008, 12:24 AM
CDRIVE's Avatar
CDRIVE CDRIVE is offline
Registered User
 
Join Date: Jan 2008
Posts: 73
Quote:
Originally Posted by adamrlee
actually Default Beep is played.
Actually, 'Brouse' is correct. Your VB Beep will be anything you set the system 'Default Beep' to be. I just changed mine to 'Ring.wav', so a Beep statement in VB now sounds like an out going telephone ring.
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.
Reply With Quote
  #12  
Old 06-10-2008, 07:18 PM
dmb-job dmb-job is offline
Registered User
 
Join Date: Jul 2004
Location: St. Louis, Mo
Posts: 111
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
Reply With Quote
  #13  
Old 06-11-2008, 12:50 AM
CDRIVE's Avatar
CDRIVE CDRIVE is offline
Registered User
 
Join Date: Jan 2008
Posts: 73
Quote:
Originally Posted by dmb-job
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
You might be interested to know that unlike the VB Beep, the Beep API takes two arguments and can generate pure single frequency tones with a specified duration. This code produces a 800Hertz tone that's 500mS long.
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
This code block generates Morse code:
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
Reply With Quote
  #14  
Old 06-11-2008, 04:01 AM
dmb-job dmb-job is offline
Registered User
 
Join Date: Jul 2004
Location: St. Louis, Mo
Posts: 111
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
Reply With Quote
  #15  
Old 06-11-2008, 09:42 AM
CDRIVE's Avatar
CDRIVE CDRIVE is offline
Registered User
 
Join Date: Jan 2008
Posts: 73
Quote:
Originally Posted by dmb-job
Many Thanks to all you friends:
I have never used MM control.
You just sent me off to investigate Pause Click, Enabled, PauseVisible,....
I'm not sure what you're referring to? The Pause statement used in my code has nothing to do with a MMControl. It calls the Pause Sub shown in the code that I posted. The Pause Sub uses the Timer Function to create a delay.... Pause (dbl). You will not find documentation on the Pause sub in the MSDN library as it's a user created sub.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:21 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.