Question Concatenating variable to class property

reyes

New member
Joined
Aug 24, 2016
Messages
2
Programming Experience
1-3
Hi guys

I've been googling this for a while thinking I'd get a quick answer, but I can't find the response I'm looking for.

I have a class with 4 properties: Property1, Property2, Property3, Property4.

In my database, I have 4 fields also named: Property1, Property2, Property3, Property4.

I'd like to achieve something like this, which I know won't work, but here it is:

VB.NET:
dim I as byte

for I = 1 to 4
    
    dbRow("Property" & I) = MyClass.Property & i

next

I remember looking into this on a VBA project ages ago, but I can't remember whether the answer was "can't be done", or whether I just went with another option. This time, my curiosity needs satisfying!

Thanks in advance.
 
Have a look at reflection and GetProperty/GetValue.
 
Back
Top