You can create a Sub, and name it "ToolStripButton1_Click".
Also include "Handles" as well as which event this method should run on. In this case it runs on "ToolStripButton1.Click"
VB.NET:
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
MsgBox("You clicked on Button1")
End Sub
For i = 1 To 50
Me.BackColor = clr(Rnd() * 9)
Next
End Sub
----------------
I am already using a sub. I want to use an IF condition saying that IF ToolStripMenuItem is clicked, then Run the code above. And If other ToolStripMenuItem is Clicked, Stop.
You want to start the loop from 1 to 50 by clicking a button,
and stop the loop (if it it still running) by clicking another button?
Is this what you are trying to do?
And also I want the loop [which is already in PRIVATE SUB] to start when a button is clicked on ToolStripMenu. I could not able to use click event cause I cannot use Private Sub under another Private Sub.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.