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

Global Object ?

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


P: n/a
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
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
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...

Nov 20 '05 #2

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

P: n/a
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

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
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...

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.