Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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",QAcrowdche er()&"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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
what is this called? : < | Excel Worksheet Functions | |||
Called subs versus functions | Excel Programming | |||
Frustrated with VBA so-called help | Excel Programming | |||
How can a UDF be called from a formula? | Excel Worksheet Functions | |||
XLA function called twice | Excel Programming |