Enum NumberSize
EightBits = 8
SixteenBits = 16
ThirtyTwoBits = 32
SixtyFourBits = 64
HundredTwentyEightBits = 128
End Enum
:) IMHO in this particular case, there is no effective use of the enumeration (see #4). There is no checks on invalid enumeration values either; most common call of the CBin_Number function was performed with argument CType(size, NumberSize) where size is an integer. It is hard to find best practices for enumerations since it just grouped constants. Usually all enumeration replaced by the Strategy Pattern during refactoring (see http://sourcemaking.com/refactoring/replace-type-code-with-state-strategy[^] or http://www.jeremyjarrell.com/archive/2007/10/28/64.aspx[^]). Type casting to enumeration datatype does not do validation, so a callie have to validate enumaration value by itself. However, by decalaring enumeration as
Enum NumberSize
Bit_8
Bit_16
Bit_32
Bit_64
Bit_128
End Enum
you may perform range (in)validation InputNumberSize < NumberSize.Bit_8 OrElse InputNumberSize > NumberSize.Bit_16, it also allows compliler to optimize Select statement code execution. Do you think change NumberSize to an integer type would introduce more problems?