Multiple Form Query

GornHorse

Well-known member
Joined
May 27, 2003
Messages
105
Location
Australia
Hi There,

Probably an extremely simple answer to what should be an easy question, but this has me stumped.

I have a multiple-form windows-based application written in vb.net. The forms are designed within visual studio, so are already created.

I know how to open one form from another; however, how do i access the public variables from form2 that i have created within form1?

When i do something like...
dim blah = form1.
the intellisense only comes up with the members relating to the windows.forms class, but no objects within the form1 class.

How on earth do i declare form1 so that i can access the public variables within it from form2?

A quick response will be much appreciated.

Regards,
Michelle
 
If you declare your variables like:
Code:
Public variablename as variabletype
Then you should be able to use them like this:
Code:
Dim f1 as new Form1()
f1.variablename = value
 
Hi there, nothing, i cannot get this to work.

Within Form1 i have the following:
Public valSelectedRow as integer
Public valSelectedFile as integer
Public valSelectedPart as integer


Within Form2 i have the following:
dim myForm1 as new Form1()
then, within the myForm2.load event...
dim blah = myForm1.valSelectedRow

It does not like having the ".valSelectedRow" after the myForm1, and will not build as a result.

What on earth am i doing wrong - or what am i emitting that i require?

Passing the values between asp.net pages is so easy, why arent applications the same??

Please offer some further details.

Regards,
Michelle
 
Hang on...
Seems to be working now, just not appearing through intellisense. I must have done something to it so that it does not show... i dont know, but, none-the-less, it works now, and thats the main thing.

Thanks for your help with this!

Cheers,
Michelle
 
Hi, me again.

Im actually still having trouble. Its not passing the value from form1 to form2 - its passing nothing. Any ideas why its going through as null?

Thanks again,
Michelle:confused:
 
Last edited by a moderator:
Back
Top