Dynamic Class Property Name

  • Thread starter Amy Blankenship
  • Start date
A

Amy Blankenship

James A. Fortune said:
James said:
'& DataHolder.Item(propArray(i)) [instead of reportInfo(propArray(i))]

That won't work. The user-defined type can't use Item to refer to an
element. Maybe Dick's idea will work using

DataHolder.Properties(propArray(i))

That's exactly why I came here asking the question. In other languages I
use, it is quite easy to get at an object's properties if you have a string
with the property name in it. In fact, that's what Objects are _for_ in
ActionScript 3. Dictionaries, by contrast, can have literally anything in
the key value, including an object (in AS3).

-Amy
 
R

Robert Morley

Sorry, I've been offline for the last 24 hours and am just catching up.

Let's say you've read in the data from your query, and you're storing qCount
in a long variable called lngQCount. In your class, you would have:

Public Property Get qCount() As Long
qCount = lngQCount
End Property

Public Property Get Properties(ByVal strPropName As String) As Variant
Select Case strPropName
Case "qCount"
Properties = Me.qCount 'or Properties = lngQCount
...
End Select
End Property

Does that cover it, or am I not understanding something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top