Solved

Count of Enum ???

Posted on 2001-09-09
5
1,400 Views
Last Modified: 2009-12-16
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
Comment
Question by:Alon1001
5 Comments
 
LVL 7

Expert Comment

by:Vbmaster
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

by:
andyclap earned 50 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

by:rspahitz
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

by:Alon1001
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

by:rspahitz
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now