Hi all,
I am a visual studio begginer and I have some problems in programming a simple app. What I want to do is to show the current step into a label at a random time interval.
Example. Total steps - value specified in textbox1 is 10
Step 1....after 10sec.....label shows Message 1
Step 2....after 15sec.....label shows Message 2
Step 3....after 5sec.......label shows Message 3
.....................................................................
Step 10...after 8sec.......label shows Message 10
Below is the code I have managed to write so far. Can anyone please help me with this. I would like to thank you in advance. I would really appreciate your help.
I am a visual studio begginer and I have some problems in programming a simple app. What I want to do is to show the current step into a label at a random time interval.
Example. Total steps - value specified in textbox1 is 10
Step 1....after 10sec.....label shows Message 1
Step 2....after 15sec.....label shows Message 2
Step 3....after 5sec.......label shows Message 3
.....................................................................
Step 10...after 8sec.......label shows Message 10
Below is the code I have managed to write so far. Can anyone please help me with this. I would like to thank you in advance. I would really appreciate your help.
VB.NET:
Private Sub B2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B2.Click
counter = 1
Randomize()
Timer1.Enabled = True
Timer1.Interval = Int(10000 * Rnd())
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim a As Integer
a = Val(TextBox1.Text)
If counter >= a Then
Timer1.Enabled = False
counter = 1
Else
Label1.Text = "Message: " & counter.ToString
counter = counter + 1
End If
End Sub
Last edited by a moderator: