I have a class with a variable employeeID as global variable.
I also have a subroutine that uses the same name:
Sub GetEmployee(employeeID as String)
Get the data
Assign the Global variables.
End sub
I want to assign the Global variable to the local variable. Is there a way
to do this easily without changing the name. I know there is a way to
reference the global variable but I can't remember what it is.
Thanks,
Tom
Mattias Sjögren - 18 Apr 2007 19:48 GMT
>I have a class with a variable employeeID as global variable.
There are no truly global variables in VB.NET. I assume you mean a
field declared at the class level.
>I also have a subroutine that uses the same name:
>
[quoted text clipped - 8 lines]
>to do this easily without changing the name. I know there is a way to
>reference the global variable but I can't remember what it is.
Just prefix it with Me (or MyClass)
Me.employeeID = employeeID
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
tshad - 24 Apr 2007 02:17 GMT
That was what I was looking for.
Thanks,
Tom
>>I have a class with a variable employeeID as global variable.
>
[quoted text clipped - 20 lines]
>
> Mattias
Phill W. - 20 Apr 2007 12:06 GMT
> I have a class with a variable employeeID as global variable.
I /really/ hope you don't /mean/ global.
The whole point of a Class is that it "encapsulates" (i.e contains) data
that is relevant to a particular /instance/ of itself.
For example:
Class Employee
Friend Sub New( ByVal Id as Integer )
_Id = Id
End Sub
Public ReadOnly Property Id() as Integer
Get
Return _Id
End Get
End Property
Private _Id as Integer
End Class
...then...
Dim fred as New Employee( 55 )
> I want to assign the Global variable to the local variable.
If you want to pass a value into a Class, use a Property.
. . .
Public Property DepartmentId() as Integer
Get
Return _DepartmentId
End Get
Set( ByVal DepartmentId as Integer )
_DepartmentId = DepartmentId
End Get
End Property
Private _DepartmentId as Integer
. . .
HTH,
Phill W.