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

multiple forms

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
13 Replies

P: n/a
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
--------------
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
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
Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
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
Nov 21 '05 #5

P: n/a
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
Nov 21 '05 #6

P: n/a
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
Nov 21 '05 #7

P: n/a
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
Nov 21 '05 #8

P: n/a
Iwdu

How did you make it owned?

Cor
Nov 21 '05 #9

P: n/a
Dim frm As New Brackets
Me.AddOwnedForm(frm)
frm.show()
Nov 21 '05 #10

P: n/a
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
Nov 21 '05 #11

P: n/a
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
Nov 21 '05 #12

P: n/a
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
Nov 21 '05 #13

P: n/a
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
Nov 21 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.