在以下的范例中,您要在 Form 中加入一个 Label、二个 CommandButton 及一个 Timer,不更改任何属性。
'在声明区中加入以下声明:
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
'加入以下程序码:
Private Sub Command1_Click()
MsgBox "计时器停掉了!", 64, "VB 的讯息框"
End Sub
Private Sub Command2_Click()
MessageBox Me.hwnd, "注意!计时器还在跑!", "API 的讯息框", 64
End Sub
Private Sub Form_Load()
Me.TimerInterval = 1000
Label1.Caption = "目前的时间是:" & Time
End Sub
Private Sub Timer1_Timer()
Label1.Caption = "目前的时间是:" & Time
End Sub