J
Joe Fallon
I have a Shared varibale in a base class and all the Shared methods in the
sub-classes use it (and CHANGE it).
I thought I was saving myself the "trouble" of Dimming this variable inside
each Shared method.
But now I wonder if I will have a problem in a multi-user environment with
code that changes this variable.
Can someone please review this sample code and let me know if it is an
issue?
Also what is the best way to clean it up? Dim the variable inside each
method?
Thanks!
----------------------------------------------------------------------
Sample code:
Base Class:
'this variable never changes once it is established on app start. Is
this OK?
Public Shared mVar1 As String
'used in sub-classes and is changed inside each method call. Is this a
huge problem?
Public Shared mVar2 As String
Sub-Class:
'method 1:
Public Shared Function Foo() As String
mVar2 = "Some string "
mVar2 &= "some more "
mVar2 &= "and more"
Return mVar2
End Function
'method 2:
Public Shared Function Bar() As String
mVar2 = "Some other string "
mVar2 &= "some more "
mVar2 &= "and more"
Return mVar2
End Function
'methods 3-10 do similar things.
sub-classes use it (and CHANGE it).
I thought I was saving myself the "trouble" of Dimming this variable inside
each Shared method.
But now I wonder if I will have a problem in a multi-user environment with
code that changes this variable.
Can someone please review this sample code and let me know if it is an
issue?
Also what is the best way to clean it up? Dim the variable inside each
method?
Thanks!
----------------------------------------------------------------------
Sample code:
Base Class:
'this variable never changes once it is established on app start. Is
this OK?
Public Shared mVar1 As String
'used in sub-classes and is changed inside each method call. Is this a
huge problem?
Public Shared mVar2 As String
Sub-Class:
'method 1:
Public Shared Function Foo() As String
mVar2 = "Some string "
mVar2 &= "some more "
mVar2 &= "and more"
Return mVar2
End Function
'method 2:
Public Shared Function Bar() As String
mVar2 = "Some other string "
mVar2 &= "some more "
mVar2 &= "and more"
Return mVar2
End Function
'methods 3-10 do similar things.