473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 36518
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jared | last post by:
Hi Does anyone know how could I load a form from another and send some parameters to it? Is there a way to identify by name instances of same form? Thx
4
by: Dan | last post by:
I am back yet again :) I am encountering an Exception that has me scratching my head. I have two forms. Form A launches Form B in response to the user clicking a button. The Constructor for Form...
5
by: Eugene Turin | last post by:
Hi people. I have a question - how to show existnig form? I create two forms: Form1 and Form2 in designer. I place a button on Form1 and I want to call a Form2 (better in modal mode!). It's...
1
by: Peter Rilling | last post by:
What events are fired when the Form.Show() and Form.Hide() methods are called. I know Load fires the first time, but what about showing and hiding the form at any point during its life cycle? ...
8
by: MV | last post by:
Why can't I run .Show() on a System.Windows.Forms object from a Class? The code works fine if i run it from an other form. The form gets visible but no controls are loaded and the mouse pointer...
7
by: Michael Erlewine | last post by:
I am trying to learn VB.Net and can't figure out how to call a from from another form. In VB6, I just issue a Load FormX, and an Unload FormX... and Show the form and there it is. I am sure it...
6
by: Daniel Kaseman | last post by:
Why won't this work? Dim frm As New Form1() Me.Close() frm.Show() HELP!
8
by: Mitch5713 | last post by:
I've got tthree forms at start up splashscreen- works fine however how do i set the time delay so it stays on the window longer,, shows longer?? Loginscreen- works fine, after the data processing...
3
by: Robert Dufour | last post by:
I have an app with code that continuously executes on a form in a timer control. I also need to show another form without interrupting the code executing in this timer. I suspect that to do that I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.