Simple Counter in VB6
Needed;
1. timer - set timer interval in its properties to 1000 ( in milliseconds)
2. label - set caption to 0
Other Timer counts only up to 10 then stop;
Counter with Start, Stop, And Reset;
1. timer - set timer interval in its properties to 1000 ( in milliseconds)
2. label - set caption to 0
Private Sub Form_Load()When you run the prog, the label will display its caption from 0 to numbers counting.
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + 1
End Sub
Other Timer counts only up to 10 then stop;
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + 1
If Label1.Caption = 10 Then
Timer1.Enabled = False
MsgBox "Time is over", vbInformation, "Message"
Label1.Caption = 0
End If
End Sub
Counter with Start, Stop, And Reset;
Dim counter As Integer
Private Sub Command1_Click() 'Start Counter
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() 'Stop Counter
Timer1.Enabled = False
End Sub
Private Sub Command3_Click() 'Reset Counter
counter = 0
Text1.Text = ""
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
counter = counter + 1
Text1.Text = counter
End Sub