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
Printable View
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
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.
LMAO, oh man im dumb :(
i fixed it
lol..
i would also like to know the answer for this
anyone know how to do this?
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
thanks for your help
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 clueQuote:
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.
now i do .. thanks to u
same here
thanks! :D