Global Object ?

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I got a Login form which user will input userid,password... etc.
I want to create a object to store (userid, logintime, deptid..etc)
that login form will create a bigger form with menu bar, (user will click
the menubar and call the form)
Every form need to display the userID and deptId, how can I create 'global
object' in the login form.
so.. every form just call that object and will get the userid ....
Thanks a lot
p.s - I hope someone can understand my question. For my past vfp
application, I only use public variable, but for .net , I got no idea...
 
I think you have a lot of options. You could make a public variable of this
object somewhere or you could make a shared/static property off the login
form. Using the shared method I think would be best considering you can get
to the data without creating a Login form object. Don't forget that the
object returned by the property needs to be shared too.

Dean
 
Hi Agnes,

That is what is named a shared class as simple as this beneath.

You can use it everywhere in your forms with
RegistryMy.FormWidth

Do not overuse it because it exist from the begin to the end in your
program.

\\\
Public Class RegistryMy
Private Shared pFormWidth As Integer
Public Shared Property FormWidth() As Integer
Get
Return pFormWidth
End Get
Set(ByVal Value As Integer)
pFormWidth = Value
End Set
End Property
End Class
///

I hope this helps?

Cor
 
Here is what I am using:

Create a new class named User or something that has your userid, logintime,
deptid properties, etc.

Then create a module, and define a "global" variable that will hold your
User class.

Module App
Public myUser As User
End Module

Class User
Private _userID As String
Private _deptID As Integer


Public Sub New(userID as String, deptID as integer)
_userID = userName
_deptID = depID
End Sub

' add other properties here

End Class

Somewhere in login code...

myUser = new User("burnsg", 99)

HTH,
Greg
 

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