Annoying Command Button!!!!

The Real Yoda

Registered User.
Local time
Today, 20:21
Joined
May 25, 2001
Messages
17
What I Want To Do Is Have A Command Button With A Label (e.g. click me to win). Only when you try to click it, the command button moves in another direction (random direction). An thereby preventing you from clicking it.

It could also come into good practise in other ways, but I just want to know how to do it.

Cheers
 
I am not sure if this is what you want, but in the On Mouse Move event of your button, try this:

Private Sub cmdNo_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngRightMost As Long, lngDeepMost As Long
Dim lngX As Long, lngY As Long

lngRightMost = Me.Width - cmdNo.Width
lngDeepMost = 2154 'Me.section(0).height - cmdNo.height

Randomize Timer
lngX = Rnd * lngRightMost
lngY = Rnd * lngDeepMost

Me!cmdNo.Left = lngX
Me!cmdNo.Top = lngY
End Sub

James.
 
If you put this code into the "on mouse move" property of a button, it will move the button around three times before it lets the user "catch" it. We have it on some of our "about" screens (those dreary little forms that tell the user who to call when things go bad...we'd like to have 'em smiling a little before they call, & 3 tries doesn't seem to get them madder):
Private Sub btnOK_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim PositionLeft As Integer
Dim PositionTop As Integer

If Counter = 2 Then
MsgBox "Just havin' a little fun... go ahead, try it again.", vbExclamation, "SENSE OF HUMOR"
Counter = 3
Exit Sub
ElseIf Counter > 2 Then
Exit Sub
End If

PositionLeft = Int((2975 * Rnd) + 1)
PositionTop = Int((4975 * Rnd) + 1)

Me.btnOK.Left = PositionLeft
Me.btnOK.Top = PositionTop

Counter = Counter + 1

End Sub
 

Users who are viewing this thread

Back
Top Bottom