Select Case statements are not very different from If Statements. In fact, all Select Case Statements can be written using an If statement, although not as easily. For example, we could write:
However, as you can see, this can get tiring fast. Using a Select Case statement, we can make this code much less repetitive and easier to read:
The Select Case statements can compare Strings, Chars, Dates, Boolean, and any number type of object. If needed, you can even have multiple condition checks (similar to the If statements "Or") by adding a comma between the values to check. For example:
Next, we will begin discussing how to use loops in VB.
Previous Next