Page tree
Skip to end of metadata
Go to start of metadata

If a lot of values in an expression are to determine the executed branch, it is advisable to use the select construct instead of multiple If statements.

Queries can be made for individual values or ranges of values.

Dim logger As LoggerUtil.Logger = LoggerUtil.getLogger(this)
Dim i As Integer
...
Select Case i
   Case 1
      logger.notice("No prime. Believe me.")
   Case 2
      logger.notice("Prime. Even it it even.")
   Case 3 To 5
      logger.notice("Don't know.")
   Case Else
      logger.error("Ask your teacher.")
End Select

 

The choice of case data types is flexible.  The structure of the statement has to follow the pattern shown (as there are no statement delimiters in Cantor).

  • No labels