468,490 Members | 2,603 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,490 developers. It's quick & easy.

How to show, load a form in VB.NET?

Hi,

This is probably a stupid question, but I can't seem to get a form to
show / load? In the older versions of VB I'd use frmMyform.show / load
myForm, etc? I looked at the help file and it showed me how to create a
new form in code and then load it, but I want to load a form when a user
clicks a button.. and hide the form that currently has focus..? I can't
seem to find this simple task in the help file.. Any help would be
greatly apprecaited..

Thanks

Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
13 30924
gb
'Form name to be opened: myFor

'Inside on click of button su
Dim frm as New myFor
myForm.Show(
Hope this helps.
Nov 20 '05 #2
That code is only for a new form right? I want to open an existing form
by name? Thanks so much..

Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
* Tim Smallwood <do*******@netscape.net> scripsit:
This is probably a stupid question, but I can't seem to get a form to
show / load? In the older versions of VB I'd use frmMyform.show / load
myForm, etc? I looked at the help file and it showed me how to create a
new form in code and then load it, but I want to load a form when a user
clicks a button.. and hide the form that currently has focus..?


<URL:http://www.google.de/groups?selm=u%23xQOutWDHA.2100%40TK2MSFTNGP11.phx. gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
gb
You can use that for an exiting form

This article explains it well

http://msdn.microsoft.com/library/de...adingToNET.asp
Nov 20 '05 #5
"Tim Smallwood" <do*******@netscape.net> schrieb

This is probably a stupid question, but I can't seem to get a form
to show / load? In the older versions of VB I'd use frmMyform.show /
load myForm, etc? I looked at the help file and it showed me how to
create a new form in code and then load it, but I want to load a form
when a user clicks a button.. and hide the form that currently has
focus..? I can't seem to find this simple task in the help file.. Any
help would be greatly apprecaited..


To show a Form:
dim f as new Form2
f.Show 'or f.ShowDialog

If you want to hide a Form and show another one, you shouldn't use a Form as
the startup object in the project properties. This should only be done if a
Form is shown from the start til the end of the application. Instead, use
your own Sub Main as the startup object:

sub main
dim f as new Form1
f.show
application.run()
end sub

To show another Form and hide the start Form:
dim f2 as Form2
f2 = new form2
f2.show
Me.visible = false

To stop the application - this doesn't happen automatically when the start
form closes because the startup object is not a Form - you must call
Application.ExitThread.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
Thank you so much! I really appreciate it! Geesh. I was pulling my hair
out!

Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
Thank you so much.. Can't I exit the application by using "End" ? Just
cuirous..
Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #8
I guess coming from a NON programming background, I really liked the way
it worked in VB6.0.. It was a whole lot easier, .. I realize there's a
good reason for this, but it's way to complicated to have to create an
instance of a form to just show a form! Yikes! hehe.. Thanks so much..

Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9
I've decide to use the Tab Control in this case to save the memory and
the trouble of opening and closing several forms as the scope of the
project has just changed and I don't want to open and close so many
forms.. I'm curious if more memory is used with one form and a tab
control, or by having several forms and hiding and showing them?

Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #10
"Tim Smallwood" <do*******@netscape.net> schrieb
I guess coming from a NON programming background, I really liked the
way it worked in VB6.0.. It was a whole lot easier, .. I realize
there's a good reason for this, but it's way to complicated to have
to create an instance of a form to just show a form! Yikes! hehe..
Thanks so much..


It might have been a little easier but at the cost of being less flexible.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #11
"Tim Smallwood" <do*******@netscape.net> schrieb
Thank you so much.. Can't I exit the application by using "End" ?
Just cuirous..


No, there is no reason to use "End". Always try to quit the application the
right way.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #12
If you are holding all the forms open in memory and using Show/Hide,
then a single form with a tab control will use less memory. If you are
opening and closing the forms, then multiple forms uses less memory, at
the expense of some processing time.

Do not get too worried about the difference between the two, unless you
are seriously short of resources, there is very little difference
between the two methods. Your client's requirements are far more
important.
Thank you so much.. Can't I exit the application by >using "End" ?
Yes, same result.

Armin wrote :If you want to hide a Form and show another one, you >shouldn't use a

Form as the startup object in the project >properties. This should only
be done if a Form is shown >from the start til the end of the
application. Instead, >use your own Sub Main as the startup object.

I agree. I always use Sub Main, even if there is only one form as this
gives far greater coding flexibility.

VB.Net needs a different mind set to VB6. I suggest you get used to
declaring forms and classes etc, it is well worth the effort to get the
most out of .Net.

As a suggestion, make sure there is as little code in the form(s) as
possible. Put all the logic in classes and call the functions as needed.
This makes the code easier to maintain and debug.

Do you know someone who codes in C++ or C#? If so, pick their brains
about how they would structure a similar application.

James

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #13
> >Thank you so much.. Can't I exit the application by >using "End" ?

Application.ExitThread()

eric

"James R" <an*******@devdex.com> wrote in message
news:eR*************@TK2MSFTNGP11.phx.gbl...
If you are holding all the forms open in memory and using Show/Hide,
then a single form with a tab control will use less memory. If you are
opening and closing the forms, then multiple forms uses less memory, at
the expense of some processing time.

Do not get too worried about the difference between the two, unless you
are seriously short of resources, there is very little difference
between the two methods. Your client's requirements are far more
important.
Thank you so much.. Can't I exit the application by >using "End" ?


Yes, same result.

Armin wrote :
If you want to hide a Form and show another one, you >shouldn't use a

Form as the startup object in the project >properties. This should only
be done if a Form is shown >from the start til the end of the
application. Instead, >use your own Sub Main as the startup object.

I agree. I always use Sub Main, even if there is only one form as this
gives far greater coding flexibility.

VB.Net needs a different mind set to VB6. I suggest you get used to
declaring forms and classes etc, it is well worth the effort to get the
most out of .Net.

As a suggestion, make sure there is as little code in the form(s) as
possible. Put all the logic in classes and call the functions as needed.
This makes the code easier to maintain and debug.

Do you know someone who codes in C++ or C#? If so, pick their brains
about how they would structure a similar application.

James

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jared | last post: by
4 posts views Thread by Dan | last post: by
5 posts views Thread by Eugene Turin | last post: by
1 post views Thread by Peter Rilling | last post: by
8 posts views Thread by MV | last post: by
7 posts views Thread by Michael Erlewine | last post: by
6 posts views Thread by Daniel Kaseman | last post: by
8 posts views Thread by Mitch5713 | last post: by
3 posts views Thread by Robert Dufour | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.