Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1580
  • Last Modified:

Count of Enum ???

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
Alon1001
Asked:
Alon1001
1 Solution
 
VbmasterCommented:
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
 
andyclapCommented:
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
 
rspahitzCommented:
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
 
Alon1001Author Commented:
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
 
rspahitzCommented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now