Solved

For...each loop and Custome Types

Posted on 2002-05-02
9
132 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 50 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

726 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