Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Count of Enum ???

Posted on 2001-09-09
Medium Priority
1,516 Views
Hi.

How can i know (if i can) how match prop in Enum.

Exsample:

Enum Test
A = 10
B = 20
End Enum

Need to get 2.

that then i can do loop like this :

for i = 1 to UBound(Test)...
next i

0
Question by:Alon1001
[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

LVL 7

Expert Comment

ID: 6468301
No can do. Unless you store the values somewhere else (in a string array or something) you can not get the name of the enum variables, nor the values.
0

LVL 6

Accepted Solution

andyclap earned 150 total points
ID: 6468869
A common pactice is to use two extra values, for example
Enum Test
[Test_Min]=10
A = 10
B = 20
[Test_Max]=20
End Enum

by putting the square brackets around the values, you can hide them from the normal properties list. It's usually used for sequential enums.
0

LVL 22

Expert Comment

ID: 6472347
Enum is a numbered list of constants.

In the same way that you really can't ask VB to give you a count of how many variables you've used, you also can't ask it to give you how many constants you've used.

For example,

Enum Test
A = 10
B = 20
End Enum

is the same as

Const A = 10
Const B = 20

except that they are grouped together under the "object" name of "Test".  This "object" does not have any properties, methods or events so you can't do much with it except use it's "variables."
0

Author Comment

ID: 6473066
Yes, u right - Enum is like const, but maybe have
api function that give the size of the object ???
and then maybe i can have the number "variables" in the
Enum ?

0

LVL 22

Expert Comment

ID: 6475015
I've never seen a way to get that, but maybe there's a way using the Scripting object, since it allows you to get other "internal" program stuff.
0

## Featured Post

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
###### Suggested Courses
Course of the Month5 days, 6 hours left to enroll

#### 670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.