Refer to a class property using a variable?
<p>I have a collection (<code>employees</code>) of employee that contain <code>name</code>, <code>id</code>, <code>office</code>, and <code>officeto</code> fields. 
I need to printout this information in equally spaced columns. So i need to find the length of the longest string name, office, officeto...and add spaces to make the columns equally spaced.<br>
I know how to do this using a recordset sending the field names into a function. 
So my question is... Is it possible to refer to a class property (name,  office, officeto) by using a variable (similar to rst! [fieldname]). 
I tried setting it up like it was a recordset loop on a field, but it doesnt compile.  The error is class.property not defined. </p>

<pre><code>Public Function PropertyLen(ByVal Property As String, ByRef Employees As colEmployees) As Integer

'This function uses a passed in class property, and returns the len of the longest class property in collection

On Error GoTo ErrorHandler:

Dim Emp As clsEmployee
Dim intLen As Integer 
Dim lngCount As Long

For lngCount = 1 To Employees.Count

       Set Emp = Employees.Item(lngCount)

       If Len(Trim(Emp.Property)) &gt; intLen Then
            intLen = Len(Trim(Emp.Property))
       End If

       Set Emp = Nothing  
Next

    FieldLen = intLen

ExitFunc:
'clean up
    Set Emp = Nothing
    Exit Function

ErrorHandler:
    modErrorHandler.DisplayUnexpectedError Err.Number, Err.Description
    Resume ExitFunc

End Function
</code></pre>