I've been playing with global variables today. What I'm expecting the program to do is declare Change as "Not Changed" at the class-level. Upon clicking the button, a timer is enabled and set to an interval of 2 seconds; after which it will change the variable to "Change." The routine will stay in a Do Until loop until the variable has been changed by the timer. Once the loop recognizes the change, the loop breaks and the routine displays the new Change variable on Label1.
I guess I'm missing a big concept of VB.NET. Will someone help me out?
I guess I'm missing a big concept of VB.NET. Will someone help me out?
Code:
Public Class Form1
Public Shared Change As String = "Not Changed"
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Change = "Changed"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label1.Text = Change
Timer1.Interval = 200
Timer1.Start()
Do Until Change = "Changed"
Me.Refresh()
Loop
Label1.Text = Change
End Sub
End Class