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
Solved

For...each loop and Custome Types

Posted on 2002-05-02
9
131 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 73
VBA: Select SQL query based on a config Sheet v2 11 49
MS SQL Update query with connected table data 3 38
transition to visual .net from vb6 5 37
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…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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