Generate random values?

L

Larry

Hi all,

Running Access 10 Developer

I have a client who wants to do the following. She is a teacher, and wants
a program that will generate sounds randomly over a one hour time span.
However, she wants to be able to specify the average time between beeps.
For example, she wants an average of 1 1/2 minutes (90 seconds) between
beeps, but she wants them to fire at random intervals. So for that hour,
there needs to be 40 beeps randomly generated. I intend to include a WAV
file, and just play that when the code fires.

There will actually be three of these running concurrently, each needing to
fire a different WAV file. (She teaches disabled kids, and each of the
three groups needs a different sound generated at different times. The
first group may need a sound every 1 1/2 minutes on average, but the other
group only 5 minutes on average.) She will enter the interval values on the
forum for the three groups in seconds.

Ideally, I would have one form where she can enter the average between beeps
for the three different groups, then hit a cmd button to run it. Can this
be done in VB?

Thanks in advance,
Larry
Maximize Software, Inc.
 
P

PC Datasheet

Larry,

This is far from being as simple as it sounds. I can create the form you need.
If you would like my help, contact me at the email address below.
 
M

Marshall Barton

Larry said:
Running Access 10 Developer

I have a client who wants to do the following. She is a teacher, and wants
a program that will generate sounds randomly over a one hour time span.
However, she wants to be able to specify the average time between beeps.
For example, she wants an average of 1 1/2 minutes (90 seconds) between
beeps, but she wants them to fire at random intervals. So for that hour,
there needs to be 40 beeps randomly generated. I intend to include a WAV
file, and just play that when the code fires.

There will actually be three of these running concurrently, each needing to
fire a different WAV file. (She teaches disabled kids, and each of the
three groups needs a different sound generated at different times. The
first group may need a sound every 1 1/2 minutes on average, but the other
group only 5 minutes on average.) She will enter the interval values on the
forum for the three groups in seconds.

Ideally, I would have one form where she can enter the average between beeps
for the three different groups, then hit a cmd button to run it. Can this
be done in VB?


Use the form's timer event to play the sounds. The command
button would set the sound, timer interval and initiate the
timer.


Here's some air code for you to ponder:

Const clngMinInterval As Long = 3000 ' 3 seconds
Private strWaveFile as String 'path to wave file
Private lngInterval As Long

Sub button_Click()
lngInterval = 1000 * 2 * txtAvgInterval - clngMinInterval
Randomize
Me.TimerInterval = lngInterval * Rnd() + clngMinInterval
strWaveFile = "C:\...\filename.wav"
End Sub

Sub Form_Timer()
Me.TimerInterval = 0 ' timer off for sound
PlaySound strWaveFile
Me.TimerInterval = lngInterval * Rnd() + clngMinInterval
End Sub

To play a wave file, see:
http://www.mvps.org/access/api/api0011.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top