Variable Aliasing?

kriswinner

Member
Joined
Apr 23, 2009
Messages
23
Programming Experience
10+
It is possible to alias variables in VB.NET?

Let me give you an example.

VB.NET:
s = std_GCCS.Modules(NodeNum).Communications.ConfigTag.Data
s.Format = "test data"
s.xStructure.DataType = "test data" 
s.xStructure.ArrayMember.Name = "test data"

Now to get the data back into std_GCCS.Modules(NodeNum).Communications.ConfigTag.Data, I need to have a statement like...
VB.NET:
std_GCCS.Modules(NodeNum).Communications.ConfigTag.Data = s

I do some other programming on a non-PC platform that allows 's' to be a true alias of the longer variable. Any changes to s would be reflected in the other variable (and vice versa).

Is this possible with VB.Net?

Thanks.
 
Class objects are reference types and have that behaviour. Structure objects are value types and behave like simple values (ie no reference).
 
Thanks for the quick reply, JohnH.
As soon as I saw your reply, it all was obvious!

Another alternative for the Structure objects to at least make the code look a little cleaner would have been the With / End With.

Thanks, again.
 
Back
Top