Option Explicit
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()
' Timer1 หยุดทำงาน ไม่ใช่ Timer หรือ สัญญาณนาฬิกาของระบบหยุดทำงานน่ะครับ ... คนละเรื่องกัน
' การใช้งาน MsgBox ตามปกติ
MsgBox "ขณะนี้เวลา Timer1 หยุดทำงาน.", vbOKOnly + vbInformation, "รายงานสถานะ"
End Sub
Private Sub Command2_Click()
' ความแตกต่างเมื่อเรียกใช้ Dialog Box ผ่าน Win32 API
MessageBox Me.hwnd, "คำเตือน ... เวลาจาก Timer1 ไม่ได้หยุดทำงาน.", _
"การใช้งาน Win32 API", vbOKOnly + vbExclamation
End Sub
Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
' ตั้งค่าการกระตุ้นให้ทำงานทุก 1 มิลลิวินาที
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
' แจ้งเวลาทุกๆ 1 มิลลิวินาที
Label1.Caption = Time
End Sub
|