Code Block
Module Module1
Private m_TimerID As Integer
Private Delegate Sub TimerProc(ByVal hWnd As IntPtr, _
ByVal uMsg As Integer, _
ByVal idEvent As Integer, _
ByVal dwTime As Integer)
Private Declare Auto Function KillTimer Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal nIDEvent As Integer) As Integer
Private Declare Auto Function SetTimer Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal nIDEvent As Integer, _
ByVal uElapse As Integer, _
ByVal lpTimerFunc As TimerProc) As Integer
Sub Main()
m_TimerID = SetTimer(IntPtr.Zero, 0, 3000, AddressOf TimerEvent)
Dim s As String = InputBox("Keep the app running while we wait for the timer event")
End Sub
Public Sub TimerEvent(ByVal hWnd As IntPtr, _
ByVal uMsg As Integer, _
ByVal idEvent As Integer, _
ByVal dwTime As Integer)
Dim rc As Integer = KillTimer(IntPtr.Zero, m_TimerID)
MsgBox("The timer event has fired!")
End Sub
End Module