[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

URGENT: Class Members

Posted on 2006-11-25
5
Medium Priority
?
143 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
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

829 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