Counting numbers using timer

Satyapriyanayak
Posted by Satyapriyanayak under VB.NET category on | Points: 40 | Views : 880
Public Class Form2

Dim i As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i = i + 1
TextBox1.Text = i
TextBox1.ForeColor = Color.Red

If i = 100 Then

Timer1.Enabled = False
MsgBox("Counting successfuly done")
Application.Exit()

End If

End Sub

Private Sub btncount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncount.Click
Timer1.Enabled = True
Timer1.Interval = "200"
End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Click to count up to 100"
End Sub
End Class

Comments or Responses

Login to post response