For example, the following line is valid.Ĭase 1 To 4, 7 To 9, 11, 13, Is > maxNumberĪ Case statement with multiple clauses can exhibit behavior known as short-circuiting. You can use multiple expressions or ranges in each Case clause. If no Case expressionlist clause matches testexpression and there is no Case Else statement, control passes to the statement following End Select. Although not required, it is a good idea to have a Case Else statement in your Select Case construction to handle unforeseen testexpression values. The Case Else statement is used to introduce the elsestatements to run if no match is found between the testexpression and an expressionlist clause in any of the other Case statements. If testexpression matches an expressionlist clause in more than one Case clause, only the statements following the first match run. Control then passes to the statement following End Select. If testexpression matches any Case expressionlist clause, the statements following that Case statement run up to the next Case, Case Else, or End Select statement. 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. One or more statements following Case that run if testexpression matches any clause in expressionlist. 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. This form is evaluated as testexpression = expression. The form specifying only expression is treated as a special case of the Is form where comparisonoperator is the equal sign ( =). If the Is keyword is not supplied, it is automatically inserted before comparisonoperator. Use the Is keyword with a comparison operator ( =,, , or >=) to specify a restriction on the match values for testexpression. The value of expression1 must be less than or equal to the value of expression2. Each clause can take one of the following forms: - expression1 To expression2 - comparisonoperator expression - expression Use the To keyword to specify the boundaries of a range of match values for testexpression. Multiple expression clauses are separated by commas. List of expression clauses representing match values for testexpression. 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). Runs one of several groups of statements, depending on the value of an expression.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |