While it is possible to do the things you want via reflection, it is far easier to write it out (especially with only 11 properties), and it also makes the code easier to read.
In terms of cloning an object, create a function called Clone within the class that returns an object of the same class, eg:
In terms of comparing, you can create a function within the class that takes an instance of the class of the parameter, and checks if they are the same, eg:Code:Class MyClass ... Function Clone() as MyClass Dim clonedObject as New MyClass clonedObject.PropertyA = Me.PropertyA clonedObject.PropertyB = Me.PropertyB ... clonedObject.PropertyL = Me.PropertyL Return clonedObject End Function
Copying values over is simple enough, so I'm sure you can work that part out.Code:Function IsEqual(compareTo as MyClass) as Boolean If compareTo.PropertyA = Me.PropertyA AndAlso compareTo.PropertyB = Me.PropertyB AndAlso ... compareTo.PropertyL = Me.PropertyL Then Return True Else Return False End If End Function




Reply With Quote
