Timed Random number in 2005 Express

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dracitus
    New Member
    • Feb 2008
    • 7

    Timed Random number in 2005 Express

    i have been trying to set a amount of time a random number has

    like

    Code:
    
          TextBox6.Text = CStr(Int(Rnd() * 10))
    
    ' This variable will be the loop counter.
    Private counter As Integer
    
    Private Sub InitializeTimer()
       ' Run this procedure in an appropriate event.
       counter = 0
       Timer1.Interval = 600
       Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       If counter => 10 Then
          ' Exit loop code.
          Timer1.Enabled = False
          counter = 0
       Else
          ' Run your procedure here.
          ' Increment counter.
          counter = counter + 1
          TextBox6.Text = counter.ToString
       End If
    End Sub


    I can get the timer to run and the radom number to run but i cant seem to do both at the same time

    I would like a timed random number generatered at a set amount of time
    Thanks
  • Bum
    New Member
    • Jan 2008
    • 19

    #2
    why don't you

    Code: ( text )

    ' This variable will be the loop counter.
    Private counter As Integer

    Private Sub InitializeTimer ()
    ' Run this procedure in an appropriate event.
    counter = 0
    Timer1.Interval = 600
    Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s) Handles Timer1.Tick
    If counter => 10 Then
    ' Exit loop code.
    Timer1.Enabled = False
    counter = 0
    Else
    ' Run your procedure here.
    ' Increment counter.
    counter = counter + 1
    TextBox5.Text = CStr(Int(Rnd() * 10))
    TextBox6.Text = counter.ToStrin g
    End If
    End Sub

    you might want to use doevents, too

    Comment

    Working...