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 that creates more buttons when clicked in Visual Basic 6
DescriptionThis example shows how to make a button that creates more buttons when clicked in Visual Basic 6.
Keywordsbutton, replicating button, Visual Basic 6
CategoriesMiscellany, Puzzles and Games
 
When the form loads, it moves its button into the form's upper left corner and sizes the form to fit the button. It then positions itself randomly.
 
Private Sub Form_Load()
Dim x As Single
Dim y As Single

    Randomize
    cmdClickMe.Move 0, 0
    Me.Width = cmdClickMe.Width
    Me.Height = cmdClickMe.Height

    x = Int(Rnd * (Screen.Width - Me.Width))
    y = Int(Rnd * (Screen.Height - Me.Height))
    Me.Move x, y
End Sub
 
When you click the form's button, the event handler simply displays a new form containing a similar button.
 
Private Sub cmdClickMe_Click()
Dim frm As New Form1

    frm.Show
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated