Results 1 to 5 of 5

Thread: changing beep sound

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Hong Kong
    Posts
    62

    Question

    how can I change the beep sound? that is, suppose I have a code like this:
    Code:
    sub command1_click()
       beep
    end sub
    and I want to change the sound of beeping to another wav file, what should I do? thanks!!
    Please Visit My WebCam!!
    http://www.hmcheung.com

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    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
    Last edited by Chris; Feb 11th, 2001 at 10:30 AM.

  3. #3
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    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
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    CyberCarsten, Beep API ony work for WinNT or Win2K platform

  5. #5
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Chris, you are absolutely right!
    I tried it on Win2k: Worked fin!
    Then I tried it on: Win98: PLING!!! (Didn't work! )
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width