RE: Enumerated types
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 2 May 2007 11:36:02 -0700
One of two ways. One of which you touched on.
1. Create an Array and use a numeric counter retrieve the values (I prefer
to use a Long data type for counter varialbes because they align on a word
boundry.
Dim varLetters as Variant
Dim lngCtr As Long
Dim strOneLetter as String
varLetters = Array("A","B","C","D")
strOneLetter = varLetters(lngCtr)
2. Create a string with the letters and use a counter variable and the Mid
function to retrive a value:
Dim strAllLetters as String
Dim lngCtr As Long
Dim strOneLetter as String
strAllLetters = "ABCD"
strOneLetter = Mid(strAllLetters, lngCtr,1)
--
Dave Hargis, Microsoft Access MVP
"Peter Hallett" wrote:
I have clearly failed to understand the syntax of enumerated types. Having.
declared :-
Enum ACGroup
A = 1
B
C
D
End Enum
I cannot then access the members of the group. With J as a variable byte,
the compiler baulks at ACGroup.J or ACGroup(J). I simply wish to return A…D
for values of J between 1 and 4, respectively.
There are other ways of doing this, of course, and, in this trivial example,
probably better ways, but it would be nice to have this option available.
One alternative I could try, in the mean time, is to declare a string array
and access its members using J as an index. As an old (=elderly) ‘C’
programmer, I also tried ‘For stString = “A” To “D” …, but, hardly
surprisingly, VBA was having none of it. Would anyone be kind enough to
clarify the situation for me?
--
Peter Hallett
- Follow-Ups:
- RE: Enumerated types
- From: Peter Hallett
- RE: Enumerated types
- Prev by Date: Main form, Tab control, subforms and a query question
- Next by Date: Re: Working with Images
- Previous by thread: Re: Enumerated types
- Next by thread: RE: Enumerated types
- Index(es):
Relevant Pages
|