Solved

For...each loop and Custome Types

Posted on 2002-05-02
9
128 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
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
Comment Utility
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 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 
LVL 2

Expert Comment

by:corvanderlinden
Comment Utility
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
 
LVL 28

Expert Comment

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

 
LVL 2

Expert Comment

by:corvanderlinden
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 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…
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…

771 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