Solved

URGENT: Class Members

Posted on 2006-11-25
5
134 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:dwe0608
5 Comments
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
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

0
 
LVL 1

Author Comment

by:dwe0608
Comment Utility
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
0
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
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
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
I have to disagree with Arthur_Wood, it IS possible with VB6 and the TLIApplication object:
http://www.vb-helper.com/howto_vb6_serialize.html

0
 
LVL 1

Author Comment

by:dwe0608
Comment Utility
thats pretty good angelIII .... thats all I needed was a clear guide on that it could be done ...

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now