If you have a question, please send it to us.
1) What is an Enumeration ?
An Enumeration provides a way of grouping a collection of symbolic constants so they can be identified easily.
The underlying data type cannot be explicitly defined because all enumerations are defined with a Long data type.
An Enumeration is a value data type.
2) Can you define an Enumeration that contains three cities ?
If you do not specify any integer (Long) numbers, the first item will have a zero (0) value and subsequent items will be in sequential order.
Public Enum enMyCities1
London 'defaults to the value 0
Tokyo 'defaults to the value 1
Paris 'defaults to the value 2
Public Enum enMyCities2
London = 100
Tokyo = 200
Paris = 300
3) Is it possible to return the string names instead of the numbers from an Enumeration ?
No. This can only be achieved by creating a function that matches the numerical values to their corresponding string names.
Public Function GetCityNames(ByVal enValue As enMyCities) As String
Select Case enValue
Case enMyCities.London : GetCityNames = "London"
Case enMyCities.Tokyo : GetCityNames = "Tokyo"
Case enMyCities.Paris : GetCityNames = "Paris"
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext