473,544 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET and FORMS (Form.Show, Form.Hide ... )


I'm moving from Vb6 to VB.Net. I have a feeling this has come up
before...

The VS.Net MSDN file seems to state that the following should work:

Form1.Show
Form1.Visible = True
Form1.Hide
Form1.Visible = False
Load (Form1)
Unload (Form1) or perhaps Close (Form1)

Yet, as you know, none of these work. I also checked a book on
converting VB6 to VB.Net, and it also seems to say that the above is
correct. So I'm guessing my syntax is wrong. Corrections will be
appreciated, particularly since I've been pulling my hair out doing
this and I'm starting to run low on hair...

Thanks

Jul 21 '05 #1
13 73985
Dim f As New System.Windows. Forms.Form()

f.lblDesc.Text = "Did you instantiate your new form like this?"

f.Show() or...

f.showdialog() for modal form

Me.Close() from within form for modal or...

f.Close() or...

f.Hide()

f.dispose()

<ge***********@ lycos.com> wrote in message
news:sg******** *************** *********@4ax.c om...

I'm moving from Vb6 to VB.Net. I have a feeling this has come up
before...

The VS.Net MSDN file seems to state that the following should work:

Form1.Show
Form1.Visible = True
Form1.Hide
Form1.Visible = False
Load (Form1)
Unload (Form1) or perhaps Close (Form1)

Yet, as you know, none of these work. I also checked a book on
converting VB6 to VB.Net, and it also seems to say that the above is
correct. So I'm guessing my syntax is wrong. Corrections will be
appreciated, particularly since I've been pulling my hair out doing
this and I'm starting to run low on hair...

Thanks

Jul 21 '05 #2
Hi Genetic,

I'm guessing that you are trying to do those things from another Form. In
which case it <has> come up before and will again (and again!!)

Form1 in VB6 can be used to get at the instantiated Form. Form1.Visible is
the Visible property of the actual Form.

Form1 in VB.NET is the <class> from which instances of the form can
created. Form1 as an <object> no longer applies. Form1.Visible fails because
it is asking for the Visible property of the class, and the class doesn't have
one - it is only availble to instances of the class.

If you want to access your 'Form1' from a different Form, (or another
class, for that matter) you need to have a reference to the instance of that
Form1. This can be stored globally in a module or passed into the other
Form/class.

If this explanation only serves to raise more questions, ask away. :-)

Regards,
Fergus
Jul 21 '05 #3
Maybe you can answer a question for me, Fergus?
Not meaning to but in on someone elses thread, but its kinda related ...

I suggested
Form.Close() or ...
Form.Hide()
Form.Dispose()

Form.Close() is the method I have been taught and that I use, however, I
have run across several code samples (written by people a hell of a lot more
knowledge than me) that have used the Hide() > Dispose() method.
Whats the difference?
..
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:ep******** ******@TK2MSFTN GP10.phx.gbl...
Hi Genetic,

I'm guessing that you are trying to do those things from another Form. In which case it <has> come up before and will again (and again!!)

Form1 in VB6 can be used to get at the instantiated Form. Form1.Visible is the Visible property of the actual Form.

Form1 in VB.NET is the <class> from which instances of the form can
created. Form1 as an <object> no longer applies. Form1.Visible fails because it is asking for the Visible property of the class, and the class doesn't have one - it is only availble to instances of the class.

If you want to access your 'Form1' from a different Form, (or another
class, for that matter) you need to have a reference to the instance of that Form1. This can be stored globally in a module or passed into the other
Form/class.

If this explanation only serves to raise more questions, ask away. :-)

Regards,
Fergus

Jul 21 '05 #4
Hi What-a-Tool,

You should call Close, because this is the overload and ruler <grins>

Okay, seriously though. Calling Close will call Dispose, but will also fire
off some form events, such as the Closing and Closed event.

As for 'Hide', this simply sets the Visible property of the form to false.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"What-a-Tool" <Fr************ ***********@cox .net> wrote in message
news:WGFdb.2862 8$0Z5.24119@lak eread03...
: Maybe you can answer a question for me, Fergus?
: Not meaning to but in on someone elses thread, but its kinda related ...
:
: I suggested
: Form.Close() or ...
: Form.Hide()
: Form.Dispose()
:
: Form.Close() is the method I have been taught and that I use, however, I
: have run across several code samples (written by people a hell of a lot
more
: knowledge than me) that have used the Hide() > Dispose() method.
: Whats the difference?
: .
: "Fergus Cooney" <fi******@tesco .net> wrote in message
: news:ep******** ******@TK2MSFTN GP10.phx.gbl...
: > Hi Genetic,
: >
: > I'm guessing that you are trying to do those things from another
Form.
: In
: > which case it <has> come up before and will again (and again!!)
: >
: > Form1 in VB6 can be used to get at the instantiated Form.
: Form1.Visible is
: > the Visible property of the actual Form.
: >
: > Form1 in VB.NET is the <class> from which instances of the form can
: > created. Form1 as an <object> no longer applies. Form1.Visible fails
: because
: > it is asking for the Visible property of the class, and the class
doesn't
: have
: > one - it is only availble to instances of the class.
: >
: > If you want to access your 'Form1' from a different Form, (or
another
: > class, for that matter) you need to have a reference to the instance of
: that
: > Form1. This can be stored globally in a module or passed into the other
: > Form/class.
: >
: > If this explanation only serves to raise more questions, ask away.
:-)
: >
: > Regards,
: > Fergus
: >
: >
:
:
Jul 21 '05 #5
Hi What-a-Tool,

Tom's said it. :-)

It would never occur to me to use Hide and then Dispose (why use two lines
when one will do). I guess I would if I wanted to skip raising those close
events. But why? Let's ask these people with a hell of a lot more knowledge!!
;-)

Regards,
Fergus

ps Any relation to Peter-o-Tool, or is it just a rampant resemblance?
Jul 21 '05 #6
: ps Any relation to Peter-o-Tool, or is it just a rampant resemblance?

ROFLM*O

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:Om******** ******@TK2MSFTN GP11.phx.gbl...
: Hi What-a-Tool,
:
: Tom's said it. :-)
:
: It would never occur to me to use Hide and then Dispose (why use two
lines
: when one will do). I guess I would if I wanted to skip raising those close
: events. But why? Let's ask these people with a hell of a lot more
knowledge!!
: ;-)
:
: Regards,
: Fergus
:
: ps Any relation to Peter-o-Tool, or is it just a rampant resemblance?
:
:
Jul 21 '05 #7
101 code samples - How to Multi-Threading - form main at the bottom.
I'm thinking it's pretty safe to say whoever wrote that has a hell of a lot
more knowledge than me, as I don't have any code samples anywhere on the
web, nevermind published by Microsoft.
I've seen it in other samples too, but this is a recent one to me, that
jumped right to mind.

No relation to Peter O'Toole.
What-a-Tool - I'm a Tool and Die Maker by proffession - thats the main
reference.
Saying "What-a-Tool" in reference to someone is also like saying
"What-a-shithead". It's a derogatory comment to make about someone, and it
made me smile to take it as a screen name.
Kinda along the same lines as "Genetic.er ror" I suppose.
Name is Sean, and thanks for enlightening me.
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:Om******** ******@TK2MSFTN GP11.phx.gbl...
Hi What-a-Tool,

Tom's said it. :-)

It would never occur to me to use Hide and then Dispose (why use two lines when one will do). I guess I would if I wanted to skip raising those close
events. But why? Let's ask these people with a hell of a lot more knowledge!! ;-)

Regards,
Fergus

ps Any relation to Peter-o-Tool, or is it just a rampant resemblance?

Jul 21 '05 #8
Hi Sean,

|| What-a-Tool - I'm a Tool and Die Maker

And here we were thinking that you're a superstud -
you should have kept quiet. ;-)

|| 101 code samples

Close() is used throughout the examples while Hide() and Dispose() only
occurs once. I'd guess that it's spurious. Maybe the code was adapted from a
different language where there are different coding styles (eg, WinAPI
upbringing). Or perhaps that is that author's style. I can't see it as being
much deeper than that.

Regards,
Fergus
Jul 21 '05 #9


Thank you What A Tool and Fergus Cooney. Yes, I have more
questions...

1. This little gem in form declarations:
Public fMAIN As New System.Windows. Forms.Form
plus this in a button click event
fMAIN.Hide()
Hid the form the old fashioned way - it rebooted my computer. Crude
but effective ;) Is there an issue involved with hiding the startup
form ?

2. How do I refer to the other forms? In other words, assuming I
successfully hide the startup form, how do I show another form?

I tried this in form declarations for form1 (non startup form):
Public fONE As New System.Windows. Forms.Form
and then tried this
fONE.Show
from my startup form. I ended up with "Name fONE is not declared".
I also tried:
Public f1 As New System.Windows. Forms.Form
in a module. At this point, the module doesnt know what form I'm
referring to, since i'm not decalring inside a form. So I added:
f1 = form1
And I got "declaratio n expected" for f1 (which I just declared) .
So the confusion continues. Thank you for your explanations, even if I
dont have it fixed, I at least have a better idea as to way it's
broke. ;)

Thanks


On Sun, 28 Sep 2003 13:11:51 +0100, "Fergus Cooney"
<fi******@tesco .net> wrote:
Hi Genetic,

I'm guessing that you are trying to do those things from another Form. In
which case it <has> come up before and will again (and again!!)

Form1 in VB6 can be used to get at the instantiated Form. Form1.Visible is
the Visible property of the actual Form.

Form1 in VB.NET is the <class> from which instances of the form can
created. Form1 as an <object> no longer applies. Form1.Visible fails because
it is asking for the Visible property of the class, and the class doesn't have
one - it is only availble to instances of the class.

If you want to access your 'Form1' from a different Form, (or another
class, for that matter) you need to have a reference to the instance of that
Form1. This can be stored globally in a module or passed into the other
Form/class.

If this explanation only serves to raise more questions, ask away. :-)

Regards,
Fergus


Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6701
by: dp | last post by:
I am new to VB.NET and I have a simple question. How do I show a form from a command button click event? The code I have below is not working. I am trying to show the form frmAgent. What am I missing? Private Sub cmdNewAgent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNewAgent.Click Dim frm1 As New...
4
7986
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers) document.layers.visibility = 'visible'; else if (document.all) { document.all.style.visibility = 'visible';
1
1179
by: Christian Soltenborn | last post by:
Hi guys, I have another beginner question for you: As we in our group all don't have experience with VB, we splitted the work by creating different forms which would be programmed by different people. Now we would like to have one Form in which we have all the other forms integrated: We have a tool bar and a main area, and the forms are...
0
1396
by: Mac via DotNetMonster.com | last post by:
I have a MDI parent form and the only control on it is a panel anchored to the left hand side. I have menu items on the MDI parent that show & hide this panel. Ideally I would like it to show by not pushing out the child forms, but rather be overlapping them. Alternatively I tried creating a form the same size as the panel but run into...
13
537
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide Form1.Visible = False Load (Form1)
5
2236
by: Stephen Plotnick | last post by:
I'm very new to VB.NET, or any VB. I need to have form1 call form2 which calls form3, etc. I am able to use oledb in form1 to get the data. I build all the data for form2 and form3 from form1 I can call form2 from form1 without any probles, all the data is there. I can change to call to form2 to form3 and all the data is there and I...
1
1812
by: DBC User | last post by:
I am wondering is there any way when I do a show and hide of a form, we can do a smooth transition to the new screen like power point presentation in c#?? Thanks.
1
6162
by: Vladimir O¾ura | last post by:
I am building a Pocket PC application in C#. I have 5 forms (1 main and 4 sub forms). The main form must always load first. The sub forms are loaded from the main form. The application is run using Application.Run(new MainForm()); The user may choose to load one of the sub forms automaticaly at startup, but when I do the folowing in...
0
7426
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7368
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7610
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7774
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5914
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4920
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1843
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.