Reputation: 1
I'm a beginning programmer, and I need to know how to access and edit variables for another class. This is some example code I have
Public Class class1
Dim strName, strAge, strGender As String
Public Class class2
/ I need to edit the variables in this class. How do I do this?
Upvotes: 0
Views: 3895
Reputation: 4742
You need to make a property that exposes the variable:
Dim ThisClassVariable as String
Public Property ClassVariable as String
Get
Return ThisClassVariable
End Get
Set(ByVal Value As String)
ThisClassVariable = value
End Set
End Property
Then when you create an instance of the class named "foo" you access the variable by using foo.ClassVariable
https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx
Upvotes: 1