EmersonH.Com

Transforming Knowledge into Power

  • Increase font size
  • Default font size
  • Decrease font size
Home VB 6 Logic Case Statement

Case Statement

E-mail Print

testexpression

Required. Expression. Must evaluate to one of the elementary data types (Boolean, Byte, Char, Date, Double, Decimal, Integer, Long, Object, SByte, Short, Single, String, UInteger, ULong, and UShort).

expressionlist

Required in a Case statement. List of expression clauses representing match values for testexpression. Multiple expression clauses are separated by commas. Each clause can take one of the following forms:

  • expression1 To expression2

  • Is ] comparisonoperator expression

  • expression

Use the To keyword to specify the boundaries of a range of match values for testexpression. The value of expression1 must be less than or equal to the value of expression2.

Use the Is keyword with a comparison operator (=, , <, <=, >, or >=) to specify a restriction on the match values for testexpression. If the Is keyword is not supplied, it is automatically inserted before comparisonoperator.

The form specifying only expression is treated as a special case of the Is form where comparisonoperator is the equal sign (=). This form is evaluated as testexpression = expression.

The expressions in expressionlist can be of any data type, provided they are implicitly convertible to the type of testexpression and the appropriate comparisonoperator is valid for the two types it is being used with.

statements

Optional. One or more statements following Case that run if testexpression matches any clause in expressionlist.

elsestatements

Optional. One or more statements following Case Else that run if testexpression does not match any clause in the expressionlist of any of the Case statements.

End Select

Terminates the definition of the Select...Case construction.

Last Updated on Monday, 21 December 2009 17:00