This program shows how to make a simple beeping program which creates a sound from the CPU. This is done through a windows API and is pretty simple.
For playing the beep, we first need to declare the BeepAPI function of the kernel32 library. This can be done as following:
For playing the beep, we first need to declare the BeepAPI function of the kernel32 library. This can be done as following:
Private Declare Function BeepAPI Lib "kernel32" Alias "Beep" (ByVal dwFrequency _
As Long, ByVal dwMilliseconds As Long) As Long
As Long, ByVal dwMilliseconds As Long) As Long
Add the following code. Below we run a loop where i = frequency of the beep. BeepAPI has two arguments - dwMillisecond and dwFrequency. The frequency is provided through the loop and the dwMillisecond is provided 50. Each Beep stays for 50 milliseconds for the provided frequency.
Private Sub Form_Load()
Dim i As Long
For i = 100 To 1000 Step 10
BeepAPI i, 50
Next
End Sub
Dim i As Long
For i = 100 To 1000 Step 10
BeepAPI i, 50
Next
End Sub