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 a button quiver frantically
DescriptionThis example shows how to make a button quiver frantically in Visual Basic 6.
Keywordsbutton, quiver, move
CategoriesControls, Tips and Tricks, Puzzles and Games
 
Thanks to Gregory Hampton.

In the button's MouseMove event handler, move the mouse and then move it back. The button must move at least far enough to trigger another MouseMove event for the trick to work.

 
Private Sub Bt_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    Bt.Move Bt.Left + 30, Bt.Top + 30
    Bt.Move Bt.Left - 30, Bt.Top - 30
End Sub
 
This version moves a button a random, slightly larger distance to create a more chaotic feel.
 
Private Sub Bt2_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
Dim dx As Single
Dim dy As Single

    dx = 10 + Rnd * 50
    If Rnd < 0.5 Then dx = -dx
    dy = 10 + Rnd * 50
    If Rnd < 0.5 Then dy = -dy
    Bt2.Move m_X0 + dx, m_Y0 + dy
    Bt2.Move m_X0, m_Y0
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated