Results 1 to 3 of 3

Thread: Data Types

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    23

    Question 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.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    23

    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

  3. #3
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    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
  •  



Click Here to Expand Forum to Full Width