Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Wait, pause, timeout, standby, ????

  1. #1

    Thread Starter
    Lively Member Amerigo's Avatar
    Join Date
    Dec 2008
    Location
    PSR B1620-26 c-1
    Posts
    126

    Resolved [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

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: [2005] Wait, pause, timeout, standby, ????

    vb Code:
    1. Threading.Thread.Sleep(millisecondsTimeout As Integer)

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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

  4. #4

    Thread Starter
    Lively Member Amerigo's Avatar
    Join Date
    Dec 2008
    Location
    PSR B1620-26 c-1
    Posts
    126

    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

  5. #5

    Thread Starter
    Lively Member Amerigo's Avatar
    Join Date
    Dec 2008
    Location
    PSR B1620-26 c-1
    Posts
    126

    Re: [2005] Wait, pause, timeout, standby, ????

    Thank you, -0
    Anyone who does not wonder, is either omnipotent or a fool.
    Amerigoware <<<My Projects

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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
  •  



Click Here to Expand Forum to Full Width