Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake an annoying button game
Keywordsgame, button, move, annoying, dumb
CategoriesPuzzles and Games
 
Put a button on a form. In the button's MouseMove event handler, move the button so it is no longer under the mouse.
 
Private Sub Command1_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
'    Try holding down the Space key and moving the
'    mouse with and without the following code
'    commented out.
'
'    If (X < 0) Or (Y < 0) Or _
'       (X > Command1.Width) Or _
'       (Y > Command1.Height) Then _
'            Exit Sub

    Command1.Move _
        Rnd * (ScaleWidth - Command1.Width), _
        Rnd * (ScaleHeight - Command1.Height)
End Sub
 
Also try shrinking the form so the button barely fits and then move the mouse over it.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated