|
-
Aug 28th, 2002, 12:44 PM
#1
Thread Starter
New Member
newbie ques.. Timers
i made 5 buttons
i want the 5th button, when clicked, to click on button 1, and after 5 seconds, click on button 2.. after 5 more sec to click on button 3, then after 5 more secs button 4
please show me the code
thanks
Last edited by helper; Aug 28th, 2002 at 06:39 PM.
-
Aug 28th, 2002, 01:19 PM
#2
Huh?
If you only have 3 buttons how can it click on button 4? Is this one of those tricky word math problems?
If you already have a timer somewhere then just set its interval to 5000 and in the tick event (Or whatever the event is called now) and then fire the click event of the right button in there.
Last edited by Edneeis; Aug 28th, 2002 at 07:30 PM.
-
Aug 28th, 2002, 06:38 PM
#3
Thread Starter
New Member
LMAO, oh man im dumb 
i fixed it
-
Aug 29th, 2002, 04:07 PM
#4
Member
lol..
i would also like to know the answer for this
-
Aug 31st, 2002, 05:10 PM
#5
Member
anyone know how to do this?
-
Aug 31st, 2002, 05:35 PM
#6
PowerPoster
Here you go, put 6 buttons on the form, and add a timer control. Map the click events to the buttons and the tick event to the timer.
The five buttons will be what you want clicked, and the sixth is just to stop the timer when you want it to stop clicking the next button every four seconds.
VB Code:
Private btnLastClicked As System.Windows.Forms.Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnLastClicked = Button1
Timer1.Interval = 4000
Timer1.Stop()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
btnLastClicked = Button1
MessageBox.Show("Button 1 clicked")
Timer1.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
btnLastClicked = Button2
MessageBox.Show("Button 2 clicked")
Timer1.Start()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
btnLastClicked = Button3
MessageBox.Show("Button 3 clicked")
Timer1.Start()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
btnLastClicked = Button4
MessageBox.Show("Button 4 clicked")
Timer1.Start()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
btnLastClicked = Button5
MessageBox.Show("Button 5 clicked")
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
If btnLastClicked Is Button1 Then
Button2_Click(sender, e)
Return
End If
If btnLastClicked Is Button2 Then
Button3_Click(sender, e)
Return
End If
If btnLastClicked Is Button3 Then
Button4_Click(sender, e)
Return
End If
If btnLastClicked Is Button4 Then
Button5_Click(sender, e)
Return
End If
If btnLastClicked Is Button5 Then
Button1_Click(sender, e)
Return
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Timer1.Stop()
End Sub
-
Aug 31st, 2002, 09:56 PM
#7
Member
-
Aug 31st, 2002, 11:19 PM
#8
PowerPoster
No problem. I am sure you could change the timer tick event code to reduce the if statements, maybe something like a select case statement.
-
Aug 31st, 2002, 11:23 PM
#9
Member
Originally posted by hellswraith
No problem. I am sure you could change the timer tick event code to reduce the if statements, maybe something like a select case statement.
yea, i just wanted to see how the timer works, cause i had no clue
now i do .. thanks to u
-
Aug 31st, 2002, 11:24 PM
#10
Thread Starter
New Member
same here
thanks!
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
|