Hi Programmers,
I'm making a worksheet for students to enter answers in. To make this
more exciting, I've collected numerous sounds, such as crowds booing
and cheering, and used the following:
in a worksheet cell:
=IF(ISBLANK(I23), "E",
IF(I23<>"M",QCcrowdboo()&"D",IF(I23="M",QAcrowdcheer()&"C")))
(note that the "E", "D", and "C" in this only pertain to displaying
different Wingdings hands.)
in VBA:
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000
Private Declare Function PlaySound Lib _
"winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
-------------------------------
Private Sub PlaySoundFile(rsPath As String)
PlaySound rsPath, 0, SND_ASYNC Or SND_FILENAME
End Sub
-------------------------------
Public Function QAcrowdcheer() As String
PlaySoundFile "C:\Windows\Media\QAcrowdcheer.wav"
Cheer = vbNullString
End Function
-------------------------------
Public Function QCcrowdboo() As String
PlaySoundFile "C:\Windows\Media\QCcrowdboo.wav"
Boo = vbNullString
End Function
-------------------------------
However, I've collected many more sounds, such as different crowds
clapping, booing, laughing, etc., and added more public functions, like
QAcrowdcheer2, QCcrowdboo2....and want to randomize the calling of
these sounds.
So, for a correct answer typed in a cell of the worksheet, call any
function that begins with QA, and for a wrong answer, call any function
that begins with QC...making it random each time.
Thanks much
Bookmarks