Solved

URGENT: Class Members

Posted on 2006-11-25
5
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18011200
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
ID: 18011211
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
ID: 18011379
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18011468
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
ID: 18013104
thats pretty good angelIII .... thats all I needed was a clear guide on that it could be done ...

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 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