I do have a class ClientClass with multiple properties. Each object loads client's data from the database. There are also two arrays PropertyName and DBField, which I use as dictionary to get each property (assume all values are strings for simplicity).
client is an object of ClientClass and clientrecord is a recordset - a record in DB table
in short I would like to go through my properties and assign them values from DB like
Public Class ClientClass
Public person_name As String
Public person_lastname As String
Public person_middlename As String
Public person_firmFlag As String
Public person_firmName As String
End Class
// then in the code:
for i=1 to n 'n is a number of properties
client.{property(propertyname(i)).value}=clientrecord.Fields(DBFields(i)).value.tostring
next i
what is the proper way to address properties of client object in this case?
thanks!
question from:
https://stackoverflow.com/questions/65829452/vb-how-to-access-the-properties-of-the-class-by-the-name 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…