Solved

For...each loop and Custome Types

Posted on 2002-05-02
9
130 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
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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

770 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