View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Boolean Declaration

Basically, you can't do that exactly as you want. You can declare Height as
Boolean, and then have constants TALL and SHORT equal to TRUE and FALSE.
E.g.,

Dim bHeight As Boolean
Const TALL = True
Const SHORT = False

Another way is to use an Enum variable type, which is really a Long type.
The enum must be declared before and outside of any Sub or Function
procedure.

Enum Height
TALL = True
SHORT = False
End Enum

Then, declare a variable of this type.

Dim H As Height

and give it a value.

H = TALL
' Or
H = SHORT

Note that declaring a variable as an enum type does NOT prevent any other
value from being assigned to that variable. For example, it is perfectly
legal to assign any valid Long value to the H variable, even if that value
is neither TALL or SHORT.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Shatin" wrote in message
...
Hi All,

Say I have a variable called Height and I want to declare it as a Boolean
variable with possible values "Tall" or "Short" rather than True or False.
How should I declare it?

TIA