[RESOLVED] [2005] Wait, pause, timeout, standby, ????
My program is supposed to display a randomly generated sentence on the screen (something like a screensaver) Then 'wait' for a random period between 1 and 5 minutes before cycling through to generate another sentence.
How do I do that?
Code:
Do
~~generate sentence
~~Display and speak sentence <---(I don't have a clue how to do either of those)
Dim Seconds As Integer
Dim MS As New Random
Seconds = MS.Next(60, 300)
Seconds = (Seconds * 1000)
'WAIT(Seconds)
Loop
Re: [2005] Wait, pause, timeout, standby, ????
vb Code:
Threading.Thread.Sleep(millisecondsTimeout As Integer)
Re: [2005] Wait, pause, timeout, standby, ????
Don't use sleep, because that will stall your whole program.
Add a timer to your form and just set the interval to some time between 1 and 5 minutes:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New Random()
Timer1.Interval = r.Next(1000, 5001) * 60
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim r As New Random()
Timer1.Enabled = False
' Your code to switch the sentence
Timer1.Interval = r.Next(1000, 5001) * 60
Timer1.Enabled = True
End Sub
Re: [2005] Wait, pause, timeout, standby, ????
???
End of statement expected.
Do I replace "millisecondsTimeout" with my random number?
Re: [2005] Wait, pause, timeout, standby, ????
Re: [2005] Wait, pause, timeout, standby, ????
If this is resolved, please mark it resolved at the top of the thread under the Thread Tools drop down :)