by C. David Johnson (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sun 10th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Chase the Button.
Private Sub cmdButton_Click()
MsgBox "You Caught me", vbOKOnly, "If you see this You cheated"
End Sub
Private Sub cmdButton_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim vHMid As Variant
Dim vWMid As Variant
vHMid = cmdButton.Height / 2
vWMid = cmdButton.Width / 2
If X < vWMid Then
cmdButton.Left = cmdButton.Left + 20
ElseIf X > vWMid Then
cmdButton.Left = cmdButton.Left - 20
End If
If Y < vHMid Then
cmdButton.Top = cmdButton.Top + 20
ElseIf X > vWMid Then
cmdButton.Top = cmdButton.Top - 20
End If
If cmdButton.Top <= 0 Then cmdButton.Top = Int((1000 * Rnd) + 1)
If cmdButton.Top + cmdButton.Height >= frmmain.Height Then cmdButton.Top = Int((1000 * Rnd) + 1)
If cmdButton.Left <= 0 Then cmdButton.Left = Int((1000 * Rnd) + 1)
If cmdButton.Left + cmdButton.Width >= frmmain.Width Then cmdButton.Left = Int((1000 * Rnd) + 1)
End Sub