|
-
Jan 26th, 2009, 04:17 PM
#1
Thread Starter
Lively Member
[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
Anyone who does not wonder, is either omnipotent or a fool.
Amerigoware <<<My Projects
-
Jan 26th, 2009, 04:30 PM
#2
Re: [2005] Wait, pause, timeout, standby, ????
vb Code:
Threading.Thread.Sleep(millisecondsTimeout As Integer)
-
Jan 26th, 2009, 04:40 PM
#3
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
-
Jan 26th, 2009, 04:47 PM
#4
Thread Starter
Lively Member
Re: [2005] Wait, pause, timeout, standby, ????
???
End of statement expected.
Do I replace "millisecondsTimeout" with my random number?
Anyone who does not wonder, is either omnipotent or a fool.
Amerigoware <<<My Projects
-
Jan 26th, 2009, 04:50 PM
#5
Thread Starter
Lively Member
Re: [2005] Wait, pause, timeout, standby, ????
Anyone who does not wonder, is either omnipotent or a fool.
Amerigoware <<<My Projects
-
Jan 26th, 2009, 04:53 PM
#6
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|