' Visual Basic Programming
' by Mr. Minich
' Ch. 7 Demo #2
' Purpose - to demonstrate the use of the form's MouseMove, MouseDown, and MouseUp event
Option Explicit
Private Sub Form_Activate()
Form1.ScaleMode = 0
Form1.ScaleHeight = 100
Form1.ScaleWidth = 100
lblMessage.Caption = "Don't click the mouse."
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblMessage.Caption = "You shouldn't have done that"
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblXPosition.Caption = Int(X)
lblYPosition.Caption = Int(Y)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Not (X > 0 And X < 50 And Y > 0 And Y < 50)) Then
Form1.BackColor = vbBlack
MsgBox "The bomb has exploded."
Call Restart
Else
MsgBox "You are lucky"
lblMessage.Caption = "Don't click the mouse."
End If
End Sub
Private Sub Restart()
Form1.BackColor = vbButtonFace
lblMessage.Caption = "Don't click the mouse."
End Sub