multiple forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey, quick question for you, i have this code:

[code language="vb"]
Dim frm As Form
frm.WindowState = FormWindowState.Normal
[/code]

and i have my form initialized and minimized so tis not that, but it gives
me an error saying "object reference not set to an instance of an object".
what am i doing wrong? any help would b awsome
 
Hi,

In vb.net 2002 and 2003 that will not reference the open form. You
need to have a reference to the form for it work or use the new keyword.

dim frm as new form

or

dim frm as form = me

Ken
--------------
hey, quick question for you, i have this code:

[code language="vb"]
Dim frm As Form
frm.WindowState = FormWindowState.Normal
[/code]

and i have my form initialized and minimized so tis not that, but it gives
me an error saying "object reference not set to an instance of an object".
what am i doing wrong? any help would b awsome
 
Ken,

dim frm as form = me
I have not seen this one before.

Although that it is a little bit strange code, is it in my opinion a nice
one, it explains direct what happens.

Cor
 
Sry about my post, i made a typo, the code i have is as follows:

Dim frm as form1
frm.WindowState = FormWindowState.Normal

and the rest is still true about it being initialized and such, sorry for
the mistake
 
Idwu

Probably you are searching for
Dim frm as form1
frm.WindowState = FormWindowState.Normal
me.WindowState = FormWindowState.Normal

If you have this kind of problems.
Set it in the designer properties and than open the designer created code.
That created code is mostly very nicely done.

I hope this helps,

Cor
 
kind of, i want to make the second form set to normal when the first form
closes, so on the "form closing" event, i have that code there
 
iwdu

In my opinion is the most simple way to do that to make one of the forms the
owner than you can use in the other one

me.owner.windowstate = etc.

I hope this helps,

Cor
 
i did that and made each form owned by the main form, but then when i try to
say "me.owner.windowstate = etc" it gives the error again
 
Iwdu,

I do it like this
\\\
dim frm as New Brackets 'assuming that this is a form
frm.owner = me
frm.show
///

I hope this helps,

Cor
 
i dont think the problem is with making it owner. i get the error at a
different time. i make form1 the owner of form "brackets", then in the
brackets form, when it closes, i try to have the owner's (form1) window state
be normal, not minimized and thats where i get the references error. this is
the code i use to try and change the window state:

Me.Owner.WindowState = FormWindowState.Normal

and thats the line i get the error on
 
Iwdu15

This below works for me withouth any problem

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.Owner = Me
frm.Show()
End Sub
///
\\\
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles MyBase.Load
Me.Owner.WindowState = FormWindowState.Minimized
End Sub
///

I hope this helps,

Cor
 
ur gunna kill me but ends up my code was just in the wrong order, i had this:

close()
Me.Owner.WindowState = FormWindowState.Normal

so it didnt have the form open that had an owner. well thanks a ton anyway!
il have ton of questions bc im a new programmer and like it alot so ive been
getting my hands on anything i can get, but thank you a ton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top