Reputation: 11
Visual Basic 2012: I want something like a boolean but there are three possible answers? Is there anything like this already or can you make something like this?
Upvotes: 1
Views: 118
Reputation: 20464
Really isn't necessary the generation of a new Enumeration... you could use TriState Enumeration.
An example:
Private Shadows Sub Load() Handles MyBase.Load
MsgBox(func(100)) ' Result = -2
End Sub
Public Function func(ByVal number As Integer) As TriState
Select Case number
Case Is < 100
Return TriState.False
Case Is > 100
Return TriState.True
Case Else ' Equals to 100
Return TriState.UseDefault
End Select
End Function
Upvotes: 0
Reputation: 62052
Like DonA
's answer, I'd recommend an Enum
, however... I highly recommend using -1
, 0
, and 1
.
Public Enum State
FirstState = -1
SecondState = 0
ThirdState = 1
End Enum
Now you're not just using three values, but better, you're using three signs essentially. Positive, zero, and negative.
Upvotes: 2