By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Changing the main form

P: n/a
Hi,
How do you change the main form in visual basic .net 2003?

I have a form1 as the startup form. Based on a user response as to
which mode to run the program in, i would like to transfer control of
the program to form2 or form3 and close form1. However, if I close
form1, the application will close because it is the startup form.

I guess I could make form1 hidden and form2 or form3 modal, but i was
hoping there was a better way.

Thanks for you help,
Tony
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Tony,
I would add a Shared Sub Main to Form1, display Form1 as a dialog, then
based on the result pass a new Form2 or Form3 to Application.Run.

Something like:

Public Class Form1

Public Shared Sub Main
Dim dialog As New Form1
If dialog.ShowDialog() = DialogResult.Ok Then
Dim formMain As Form
If dialog.Response = UseForm2 Then
formMain = New Form2
Else
formMain = New Form3
End If
Application.Run(formMain)
End If
End Sub

Where Response is a property that indicates what the use selected.

Hope this helps
Jay

"Tony" <to*******@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
Hi,
How do you change the main form in visual basic .net 2003?

I have a form1 as the startup form. Based on a user response as to
which mode to run the program in, i would like to transfer control of
the program to form2 or form3 and close form1. However, if I close
form1, the application will close because it is the startup form.

I guess I could make form1 hidden and form2 or form3 modal, but i was
hoping there was a better way.

Thanks for you help,
Tony

Nov 20 '05 #2

P: n/a
Thanks Jay, that put me on the right track.
Tony
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<#V*************@TK2MSFTNGP12.phx.gbl>...
Tony,
I would add a Shared Sub Main to Form1, display Form1 as a dialog, then
based on the result pass a new Form2 or Form3 to Application.Run.

Something like:

Public Class Form1

Public Shared Sub Main
Dim dialog As New Form1
If dialog.ShowDialog() = DialogResult.Ok Then
Dim formMain As Form
If dialog.Response = UseForm2 Then
formMain = New Form2
Else
formMain = New Form3
End If
Application.Run(formMain)
End If
End Sub

Where Response is a property that indicates what the use selected.

Hope this helps
Jay

"Tony" <to*******@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
Hi,
How do you change the main form in visual basic .net 2003?

I have a form1 as the startup form. Based on a user response as to
which mode to run the program in, i would like to transfer control of
the program to form2 or form3 and close form1. However, if I close
form1, the application will close because it is the startup form.

I guess I could make form1 hidden and form2 or form3 modal, but i was
hoping there was a better way.

Thanks for you help,
Tony

Nov 20 '05 #3

P: n/a
Try this out:

http://www.codeproject.com/useritems...ontextDemo.asp
"Tony" <to*******@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
Hi,
How do you change the main form in visual basic .net 2003?

I have a form1 as the startup form. Based on a user response as to
which mode to run the program in, i would like to transfer control of
the program to form2 or form3 and close form1. However, if I close
form1, the application will close because it is the startup form.

I guess I could make form1 hidden and form2 or form3 modal, but i was
hoping there was a better way.

Thanks for you help,
Tony

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.