![]() ![]() If you observe the above example, we used Select.Case statements within another Select.Case statements to implement nested Select.Case statements based on our requirements. In Visual Basic, using one Select.Case statement within another Select.Case statement is called a nested Select.Case statements.įollowing is the example of using nested Select.Case statements in Visual Basic programming language.Ĭonsole.WriteLine("Nested Switch Value: 5")Ĭonsole.WriteLine("Another Nested Switch Value: 3") Visual Basic Nested Select Case Statements If you observe the above result, the Case statement ( 20) matches the defined expression value ( 20) and executes the statements within the respective Case statement. ![]() ![]() When we execute the above Visual Basic program, we will get the result as shown below. If you observe the above example, we defined Select with multiple Case statements, and it will execute the matched Case statements with the expression value. Visual Basic Select Case Statement Exampleįollowing is the example of using select.case statement in Visual Basic programming language.Ĭonsole.WriteLine("Press Enter Key to Exit.") If all case statements fail to match with the defined expression value, then the Else block statements will be executed, and the Select statement will come to an end. In case, if the expression value matches, it will execute the particular Case statement block and execute the Select statement otherwise, it will go to the second Case statement and check whether the expression value is matching or not, the same way the search will continue till it finds the right Case statement. ![]() If you observe the above Select.Case statement flow chart diagram, the process flow of Select.Case statement will start from the Top to the Bottom, and in the first case, it will check whether the expression value matches or not. Visual Basic Select Case Statement Flow Chartįollowing is the pictorial representation of Select.Case statement process flow in Visual Basic programming language. If none of the case statements match the defined expression/ variable value, then the statements inside the Else block will be executed, and it’s more like Else block in the if.else statement. If the variable/expression value matches with any of the case statements, the statements inside of that particular case will be executed. The Select statement will evaluate the expression / variable value by matching with Case statement values (value1, value2, etc.). If you observe the above syntax, we defined a Select.Case statement with multiple case statements. Statements to Execute if No Case Matches ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |