Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a new form by clicking on a command button or a label 1

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
US
Hi everyone,
i want to know how i can make something that when you click on a label or a command button, a new form would be created or something like a message box that you can add text and some other things to it, would be created.
Thanks in advance...
 
Create a new project

Pick standard exe

In the project explorer right click form1 and add form

In the add form box pick form

Now in the design window pick form1

Click on the command button tool in the toolbox

now click and hold down the mouse button and draw your command button

Now double click the command1 button in the design window and this will create the following code for you.

Private Sub Command1_Click()

End Sub

then just add "form2.show" so that the code looks like this

Private Sub Command1_Click()
Form2.Show
End Sub

now just add this code undre the first piece

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Form2
End Sub

this makes form1 close form2 if it is being closed
 
Or you could
as above new project and add a command button
but you dont need a form 2
just add this code

Private Sub Command1_Click()
Dim Form2 As Form
Set Form2 = New Form1
Form2.Show
Form2.Caption = "Form2"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top