Sharing Class Data With Multiple Forms

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

I'm developing an application that has an initial login form. It uses a
user class that checks for a valid user. If the user is valid, it
populates public variables in the class, hides the login form and shows
the next form. Is there a way to use the variables from the user class
in the new form that opens?

Thanks,
 
Jerry said:
I'm developing an application that has an initial login form. It uses a
user class that checks for a valid user. If the user is valid, it
populates public variables in the class, hides the login form and shows
the next form. Is there a way to use the variables from the user class
in the new form that opens?

If you structure your project so that Sub Main is the startup object,
in the Sub Main code you could fire off your login screen with an:

Application.Run(LoginForm)

and the LoginForm instance defined in Sub Main becomes a global
variable, and all properties in it are also available globally. Of
course, the login form would have to open the next form in the chain.
 
Jerry said:
I'm developing an application that has an initial login form. It uses a
user class that checks for a valid user. If the user is valid, it
populates public variables in the class, hides the login form and shows
the next form. Is there a way to use the variables from the user class
in the new form that opens?

Simply put the UserClass-ObjectVar Public into a *.bas-Module.
This way it is visible to all other "Members" (Forms, Classes) in
your project.

Olaf
 
I'm developing an application that has an initial login form. It uses a
user class that checks for a valid user. If the user is valid, it
populates public variables in the class, hides the login form and shows
the next form. Is there a way to use the variables from the user class
in the new form that opens?

You have posted this question to both .NET and non-.NET groups. Please
determine which version of VB you're using and restrict your posts to the
appropriate groups. The *.vb.* are for VB6 and earlier. The .NET groups have
*.dotnet.* in their names.
 
Jeff said:
You have posted this question to both .NET and non-.NET groups. Please
determine which version of VB you're using and restrict your posts to the
appropriate groups. The *.vb.* are for VB6 and earlier. The .NET groups have
*.dotnet.* in their names.

I'm using .NET.

I saw various versions of VB being discussed on the general group and
thought that .NET was just another version.
 
....
I'm using .NET.

I saw various versions of VB being discussed on the general group and
thought that .NET was just another version.

It's enough different that it's practically a new language; that's why
there are two sets of NG's.
 
Back
Top