'Win32API Example - Beep
'
'Jon Vote
'
'02/2002
'
' 1) Create a new project. Form1 will be created by default.
' 2) Add two labels to the form, Label1 and Label2.
' 3) Add two text boxes to the form, one to the right of each label.
' 4) Add a two command buttons below the text boxes and labels
' 5) Paste the following code into the declarations section of Form1:
' --- Begin code for Form1 ---
'Windows API Example: Beep
'
'Author: Jon Vote
' Idioma Software Inc.
' www.idioma-software.com
'
'Date: 02/02
'
'(c) 2002 Idioma Software Inc.
'
Option Explicit
Private Sub Form_Load()
Me.caption = "Beep Example
Label1.Caption = "Frequency:"
Label2.Caption = "Duration:"
Text1.Text = 120
Text2.Text = 120
Command1.Caption = "&Beep"
Command2.Caption = "E&xit"
Command1.Default = True
Command2.Cancel = True
End Sub
Private Sub Command1_Click()
Dim lngRC As Long
Dim lngFrequency As Long
Dim lngDuration As Long
lngFrequency = Text1.Text
lngDuration = Text2.Text
lngRC = Beep(lngFrequency, lngDuration)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Text1_LostFocus()
Text1.Text = CLng(Val(Text1.Text))
End Sub
Private Sub Text2_LostFocus()
Text2.Text = CLng(Val(Text2.Text))
End Sub
' --- End code for Form1 ---
' 6) From the menu select Project|Add Module. Module1 will be created by default
' 7) Paste the followin code into Module1:
' --- Begin code for Module1 ---
Option Explicit
Public Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
' --- End code for Module1 ---