next form

hey..
i would like to know how would i be able to add a button to a form and wen its clicked go to another form..
thanks..
[136 byte] By [MikeyLopez] at [2007-11-19 14:07:41]
# 1 Re: next form
Add the button, and double click on it. You will generate the Click event handler. Inside the method write:

Dim nextForm as New Form2
nextForm.Top = Me.Top
nextForm.Left = Me.Left
nextForm.Width = Me.Width
nextForm.Height = Me.Height
Me.Visible = False
nextForm.Show()
jhammer at 2007-11-10 3:16:01 >
# 2 Re: next form
thanks alot that worked. But i got a question. When i get this "Sub Main was not found", how can i avoid this when creating more then 1 form.
MikeyLopez at 2007-11-10 3:17:10 >
# 3 Re: next form
Either set the properties Startup object, or create a Sub Main
To set the startup object, right-click on the project in Solution Explorer, and you will see in General option the Startup Object field. You will see all the forms in the project and Sub Main. Just select one of the forms.

To create a Sub Main (you only need to do this if showing the form is not the only thing you need to do on application startup like reading user command line arguments):
Add this sub to one of your classes:

Public Shared Sub Main()
Application.Run(New Form1());
End Sub

You can run one form, and you can also read arguments (look at MSDN)
jhammer at 2007-11-10 3:18:09 >