Für dieses Beispiel brauchen Sie ein Modul und eine Form mit einem Commandbutton und einem Label.
' #####
' Modul
' #####
Public Declare Function SetTimer Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long _
) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long _
) As Long
Public Sub Zaehler()
' Intervall = 1 Millisekunde
Static i
i = i + 1
Form1.Label1.Caption = i
End Sub
' ####
' Form
' ####
Private Sub Command1_Click()
Call SetTimer(Me.hwnd, 0, 1, AddressOf Zaehler)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call KillTimer(Me.hwnd, 0)
End Sub