Solved

URGENT: Class Members

Posted on 2006-11-25
5
135 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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

13 Experts available now in Live!

Get 1:1 Help Now