Re: globals?
- From: "AMDRIT" <amdrit@xxxxxxxxxxx>
- Date: Fri, 26 Jan 2007 13:44:12 -0600
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: Cor Ligthert [MVP]
- Re: globals?
- References:
- globals?
- From: Smokey Grindle
- Re: globals?
- From: lord . zoltar
- globals?
- Prev by Date: Creating Interactive DVDs
- Next by Date: Re: globals?
- Previous by thread: Re: globals?
- Next by thread: Re: globals?
- Index(es):
Relevant Pages
|