Re: globals?
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Sat, 27 Jan 2007 14:04:49 +0100
Amdrit
Why is this better than a module?
And it is not a singleton that word is not used in the VB language.
(While it is as well no singleton in the C world).
Your difficult class written as a nice module could be
Public Module myGlobals
private probjeGlobals as MyGlobabls
etc.
Those are therefore private to the module, only the dim is automaticly
public.
In my idea is a good written VB module therefore much nicer than a so called
often named shared class.
Cor
"AMDRIT" <amdrit@xxxxxxxxxxx> schreef in bericht
news:upnabJYQHHA.1364@xxxxxxxxxxxxxxxxxxxxxxx
I think the new preferred way is to use a singleton. Example
myglobals.instance.somedata="Test String"
public class myglobals
'Singleton Variables
private shared pobjGlobals as MyGlobals
'Instance Variables
private pstrUserName as string
private pintUserID as integer
private pstrSomeData as stirng
'Singleton Creation
shared sub new
pobjGlobals = new MyGlobals
end sub
'Instance Access
public shared readonly Property Instance as MyGlobals
get
return pobjGlobals
end get
end property
'Instance Methods
public function Login(userName as string, password as String) as boolean
'test credentials
'once successful,
me.pstrUserName = 'Some User Name
me.pstrUserID = 'Some User ID
end function
Public Function Add(intVarA as integer, intVarB as integer) as integer
return intvar1 + intvarB
end Function
'Instance Properties
public readonly property UserID as integer
get
Return pintUserID
end get
end property
Public Property SomeData as string
get
return pstrSomeData
end get
set(value as string)
pstrSomeData = value
end set
end property
end class
But yes, modules are still available.
<lord.zoltar@xxxxxxxxx> wrote in message
news:1169839610.011256.212340@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jan 26, 2:20 pm, "Smokey Grindle" <nos...@xxxxxxxxxxxxxx> wrote:
Whats the easiest way to make a global function in VB 2005? The old way
was
make a module, is that still the standard? thanks!
Yup, you can still use modules. You can also use namespaces to group
data.
.
- Follow-Ups:
- Re: globals?
- From: AMDRIT
- Re: globals?
- References:
- globals?
- From: Smokey Grindle
- Re: globals?
- From: lord . zoltar
- Re: globals?
- From: AMDRIT
- globals?
- Prev by Date: Re: globals?
- Next by Date: Re: globals?
- Previous by thread: Re: globals?
- Next by thread: Re: globals?
- Index(es):
Relevant Pages
|