469,917 Members | 1,729 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Timed Random number in 2005 Express

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

like

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.       TextBox6.Text = CStr(Int(Rnd() * 10))
  4.  
  5. ' This variable will be the loop counter.
  6. Private counter As Integer
  7.  
  8. Private Sub InitializeTimer()
  9.    ' Run this procedure in an appropriate event.
  10.    counter = 0
  11.    Timer1.Interval = 600
  12.    Timer1.Enabled = True
  13. End Sub
  14.  
  15. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  16.    If counter => 10 Then
  17.       ' Exit loop code.
  18.       Timer1.Enabled = False
  19.       counter = 0
  20.    Else
  21.       ' Run your procedure here.
  22.       ' Increment counter.
  23.       counter = counter + 1
  24.       TextBox6.Text = counter.ToString
  25.    End If
  26. End Sub
  27.  


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
Feb 9 '08 #1
1 959
Bum
19
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(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
TextBox5.Text = CStr(Int(Rnd() * 10))
TextBox6.Text = counter.ToString
End If
End Sub

you might want to use doevents, too
Feb 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

38 posts views Thread by One Handed Man \( OHM - Terry Burns \) | last post: by
3 posts views Thread by sebnunes | last post: by
12 posts views Thread by Juha Nieminen | last post: by
13 posts views Thread by Peter Oliphant | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.