I have tried the below:
Select Case Combo1.SelectedItem Or Combo2.SelectedItem
But I get the error:
Conversion from String "string here" to type 'Long' is not valid
Is it possible to have multiple select cases?
Syntax of Select Case Statement in VB.Netyour_expression: this denotes an expression which evaluates to one of the elementary Data Types supported in Microsoft VB.NET. expression_list: expression clauses that denote the match values for the expression. For the case of multiple clauses, separate them using a comma (,).
In computer programming languages, a switch statement is a type of selection control mechanism used to allow the value of a variable or expression to change the control flow of program execution via search and map.
Visual Basic is case-insensitive, but the common language runtime (CLR) is case-sensitive. For more information, see "Case Sensitivity in Names" in Declared Element Names. By default, this message is a warning.
It executes a series of statements as long as a given condition is True. The syntax for this loop construct is − While condition [ statements ] [ Continue While ] [ statements ] [ Exit While ] [ statements ] End While. Here, statement(s) may be a single statement or a block of statements.
You separate multiple values by using a comma:
Case Combo1.SelectedItem, Combo2.SelectedItem
Using Or
would make it an expression that would be evaluated before compared to the value in the Select
.
If your value in the Select
is a Long
value, then you may need to convert the strings from the controls:
Case CLng(Combo1.SelectedItem), CLng(Combo2.SelectedItem)
To address the question directly, using multiple values as a test expression in a select is not possible:
Select Case v1, v2 'Not possible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With