|
-
Jul 30th, 2001, 10:01 AM
#1
Thread Starter
Member
Enum
I need to do a project with Enum's --- I need to Get the total enum's in an array and then get the enum's that are = True ..Does anyone know of an article about this stuff???
-
Jul 30th, 2001, 10:14 AM
#2
Member
I'm pretty sure you can't go through an enum like that. Enums are not variables, but rather they are a group of constants, like:
VB Code:
Public Enum DaysOfWeek
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
End Enum
So you can't do If DaysOfWeek = True, but you can do...
VB Code:
Dim d As DaysOfWeek
d = DaysOfWeek.Tuesday
If d = True Then ' whatever
-
Jul 30th, 2001, 10:21 AM
#3
also enums are not dynamic so there would be no point to code that returns how many variables are in an enum since the number would always be the same.
-
Jul 30th, 2001, 10:49 AM
#4
Thread Starter
Member
I am using this in an application that has Privileges. I want to get all the Privs in an array using Enum's .... then create another Array with the Enum's that are set to true....Right now i have it working where it will get the Total Enum's that are true....And now i have to figure out how to get the Total Enum's...
-
Jul 30th, 2001, 11:18 AM
#5
Fanatic Member
Ok, those are not referred to as Enums, but rather elements. An enum, is, as stated, a group of constants sort of like a UDT. Also, an enum is a way to iterate through a collection or an array using the for each ... next control structure:
Code:
Dim privElement As Variant
Dim varPrivs As Variant
varPrivs = dbUserType.Privileges
For Each privElement In varPrivs
MsgBox privElement
Next
-
Jul 30th, 2001, 11:20 AM
#6
Fanatic Member
Also, you could get the total number of Elements in the array thusly:
Code:
Y = UBound(varPrivs)
For X = 0 to Y
MsgBox varPrivs(X)
Next X
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|