?
Solved

For...each loop and Custome Types

Posted on 2002-05-02
9
Medium Priority
?
137 Views
Last Modified: 2010-05-02
Hi there,

I have created a type called "Workers"
Public Type Worker
    ID As Integer
    Title As String
    FirstName As String
    MiddleName As String
    LastName As String
    Suffix As String
    JobTitle As String
    Clearance As Integer
    JobID As Integer
    HomePh As Long
    MobilePh As Long
    Address As String
    Address2 As String
    Age As Integer
    PC As Integer
    State   As String
    MaritalStatus As String
    NumKids As Integer
End Type


I then declared a variable as Worker

Public Worker as Worker

Now here's the problem. I need to be able to circulate through the whole Worker properties/sub items, what ever they're called.
How do I do it?
Is it possible?

I was thinking of declaring a variable "N" as property
then

for each N in worker
debug.print worker(n)
next

i cant do that ^^^^^^

any help???
thank you
0
Comment
Question by:romka
[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
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 6985828
And do what with them? You might be able to enumerate the properties using TypeLib functions but you still won't be able to do much with them.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6985899
0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6986057
I agree with Tim on that

You could define a Worker Class, and in that class a variant array called properties and enum on that array.
Do not like the solution myself
0
Industry Leaders: 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!

 
LVL 28

Expert Comment

by:AzraSound
ID: 6986065
I think what you are after may be this (requires to redefine your udt as a class):

http://www.devx.com/free/tips/tipview.asp?content_id=3516
0
 
LVL 2

Expert Comment

by:corvanderlinden
ID: 6986107
AzraSound this is for collections. I think he wants to make his own Enumarator (like you can in C or VB.NET)
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6986145
Oh I see...

Tim mentioned use of the TypeInfo library.  This is a valid solution, though I believe I wrote something to use it once, and it would not work from a compiled exe...only in the IDE.  Something to think about if you plan on perhaps going down that road.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6986156
>>it would not work from a compiled exe...only in the IDE

That is, querying an object's properties/values that was part of the project itself.  Loading and querying an external object was not a problem.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7698757
Hi romka,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

romka, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7755576
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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

649 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