|
|
Title | Make a button that creates more buttons when clicked in Visual Basic 6 |
Description | This example shows how to make a button that creates more buttons when clicked in Visual Basic 6. |
Keywords | button, replicating button, Visual Basic 6 |
Categories | Miscellany, 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
|
|
|
|
|
|