LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How can functions be called randomly?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is this called? : < Jake Excel Worksheet Functions 1 November 28th 06 11:01 AM
Called subs versus functions Neal Zimm Excel Programming 2 April 5th 05 06:43 AM
Frustrated with VBA so-called help davegb Excel Programming 33 March 24th 05 09:01 PM
How can a UDF be called from a formula? GuyH Excel Worksheet Functions 0 November 17th 04 03:37 PM
XLA function called twice Nigel[_9_] Excel Programming 0 November 16th 04 10:46 AM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"