|
-
May 9th, 2001, 11:02 AM
#1
Thread Starter
Junior Member
Data Types
Is there a way to define a custom data type that only allows certain values?
For instance, I would like to create a datatype of SIZE which could hold values of SMALL, MEDIUM, LARGE exclusively. I figure I could do this through making constants for each that translate to 1, 2, and 3 and then doing SIZE as a byte, but I would prefer the more streamlined method.
Thank you.
-
May 9th, 2001, 11:10 AM
#2
Thread Starter
Junior Member
Upon clicking back over to the VB Help file I noticed that under constants, the topic I had been searching, a heading for 'enumeration', which rang a bell, and thus my question is answered.
Private Enum Size
Small
Medium
Large
End Enum
-
May 9th, 2001, 11:10 AM
#3
Hyperactive Member
I think you are talking about enumeration:
The following code goes in the general declarations section of a form or module
Code:
Enum enmMySizes
SMALL = 0
MEDIUM = 1
LARGE = 2
End Enum
Then assign it to a variable to use it:
Code:
Dim Sizes as enmMySizes
If Sizes = MEDIUM Then
'Do Something
End If
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
|