Link to home
Start Free TrialLog in
Avatar of dwe0608
dwe0608Flag for Australia

asked on

URGENT: Class Members

Hi All,

If I have a class made up of say the following properties

FirstName
MiddleName
Surname
Age


and I wanted to itinerate through the class and obtain
     1.       the name of the property,
     2.       its return type (ie string, boolean and so on) and
     3.       its value

I was thinking along the lines of something similar to a For Each type thing, how would I do that ?

MTIA

Darrin
Avatar of EDDYKT
EDDYKT
Flag of Canada image

you need to use collection

i.e
Dim a As New Collection
Private Sub Command1_Click()

Dim i As Long
Dim c As Class1
For i = 0 To 10
Set c = New Class1
c.Age = i + 10
a.Add c
Next

For Each c In a
    Debug.Print c.Age
Next
End Sub


where class1 is


Option Explicit

Public FirstName
Public MiddleName
Public Surname
Public Age

Avatar of dwe0608

ASKER

I think you may have missed my query ....

using your class

I am trying to do the following

       for each p in me.class1
          debug.print p.name
          debug.print p.typedef
          debug.print p.value
       next p

I dont even know if this can be done, but I would like to see if and how it can be done.

I like the way you use a collection to hold a class of info ....

MTIA

Darrin
what version of VB are you using?  If VB 6 then what you are asking is not possible.  With VB.NET, you might be bale to achieve this using Reflection.

AW
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dwe0608

ASKER

thats pretty good angelIII .... thats all I needed was a clear guide on that it could be done ...