linking to another form

timtom1

Member
Joined
Jun 12, 2006
Messages
24
Programming Experience
Beginner
*daft* question I have a form called menu and a form called upload how do I like between them with an ok button lol

I have

VB.NET:
[SIZE=2][COLOR=#0000ff]
Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ButtonUpload_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ButtonUpload.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] upload_form [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Form
[/SIZE][SIZE=2][COLOR=#008000]'Dim upload_form As New Form
[/COLOR][/SIZE][SIZE=2]upload_form.Show()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

But it brings a new form up not the form I have already created called upload_form :confused: simple I know but its doing my head in.
 
If you have a form in your project you just need to call it directly, no need to Dim as new form.

Simply use the upload_form.show() and it should work. (Again, provided its an object in your project)
 
I now have three forms in my project the first form I create appears when I run the code how do I change that so it runs a different form 1st?
 
start your app from Sub main() (i usually put sub main in a module, but that's just me) and in sub main you can run any of the form's as an application by using Application.Run(Your form var here) then when that form is closed it goes back to sub main where you can let it reach the 'End Sub' statement and the whole app terminates or you can run other code, or start another form, etc...
 
Jugga's answer is better for what is seems like your wanting to do (multi form/point application) but if you ever did want to change just which form your are loading first:

Select "Project" from the menu strip and then "Properties" (last item), go to the "Application" tab, and changing the "Startup Form"
 
I'm afraid JB's answer is appropriate only for VB.NET 2003. Don't use a Main method at all in VB 2005. You should make your app's main form the Startup Form. If you want to display another dialgue first, like a login window, then you handle the Startup event of the application itself and display your login window as a modal dialogue there. If the login fails then you set e.Cancel to True and the main form is never created, thus the app exits gracefully.
 
Also, please post in the most appropriate forum for the topic, not just the first one you come to. This is a Windows Forms question so it should be posted in the Windows Forms forum. The VS General forum is for general questions about the VS IDE.

Moved.
 
Back
Top