ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is BEEP all there is?? (https://www.excelbanter.com/excel-programming/328750-beep-all-there.html)

Gary's Student

Is BEEP all there is??
 
Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student

Jim Thomlinson[_3_]

Is BEEP all there is??
 
Here is an API to play whatever wav file makes you happy.

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long


Private Sub Test()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

HTH

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student


Gary's Student

Is BEEP all there is??
 
Thanks, I guess the burden has shifted from programming Basic to make sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long


Private Sub Test()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

HTH

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student


Tom Ogilvy

Is BEEP all there is??
 
In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
As Long) As Long

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

Long


Private Sub Test()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

HTH

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student




Gary's Student

Is BEEP all there is??
 
Thank you both very much.
--
Gary's Student


"Tom Ogilvy" wrote:

In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
As Long) As Long

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

Long


Private Sub Test()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

HTH

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student





Jim Thomlinson[_3_]

Is BEEP all there is??
 
Thanks Tom... One more API for me ply with...

"Tom Ogilvy" wrote:

In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
As Long) As Long

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

Long


Private Sub Test()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

HTH

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student






All times are GMT +1. The time now is 07:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com