这是一篇旧文档
Public Class frmMain
Declare Function SetTimer Lib "user32" (ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As TP) As Int32
Declare Function KillTimer Lib "user32" (ByVal hwnd As Int32, ByVal nIDEvent As Int32) As Int32
Delegate Function TP(ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As Int32) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetTimer(Me.Handle, 0, 1, AddressOf TimerProc)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
KillTimer(Me.Handle, 0)
End Sub
Dim i As Integer = 0
Function TimerProc(ByVal hwnd As Int32, ByVal nIDEvent As Int32, ByVal uElapse As Int32, ByVal lpTimerFunc As Int32) As Integer
i += 1
Me.Text = i
End Function
End Class