drjoeusa
asked on
Iteration through predefined enumerations
The enumeration vbVarType includes a list of constants such as vbInteger, vbLong, vbSingle, vbDouble, vbArray with values 2, 3, 4, 5, and 8192 respectively. I want to iterate through the enumeration as have both the names of the constant and the value of the constant.
I found an example that I thought might work that uses the code:
Dim items as array
items = System.Enum.GetValues(GetT ype(FirstD ayOfWeek))
However, this doesn't work for me. Is there another way to do this?
I found an example that I thought might work that uses the code:
Dim items as array
items = System.Enum.GetValues(GetT
However, this doesn't work for me. Is there another way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's good to learn that it's not possible to do what you're trying to do. I'll do it manually until I move to .NEt. Thanks.
I can only help you with the syntax, you will have to investigate the Object names on your own.
If you have a form with some controls on it, you can run code like this:
Private Sub Command5_Click()
Dim strHeaders As String
Dim ctl As Control
Dim strAccumulator As String
strHeaders = "ControlName ControlLeftLocation" & vbCrLf
For Each ctl In Me.Controls
strAccumulator = strAccumulator & ctl.Name & " " & ctl.Left & vbCrLf
Next ctl
Debug.Print strHeaders & strAccumulator
End Sub
This code will produce output similar to this:
ControlName ControlLeftLocation
Command1 4800
Command2 5940
Label3 1440
Label4 2880
Command5 6840
Hope this helps.
JeffCoachman