From the course: Visual Basic Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Select Case

Select Case - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

Select Case

- [Instructor] The Select Case statement provides an alternative to a series of if and else/if statements. It's similar to the Switch statement in languages like Java and PHP. To add one to your code, type in the word 'select', then press the Tab key twice. Visual studio adds a snippet to your application and it puts placeholders in the snippet. They're the yellow items. And I can use the Tab key to move between the placeholders. This allows me to quickly change the value in the snippet, then move to the next place and so on. I don't need this so I'll press the Esc key, and then we'll talk about what's happening on line nine. That's the fist line in the Select Case statement that says evaluate the current value of variable name and then compare it against all the case statements written below this. I've got two case statements; Case One and Case Two. And then I have Case Else. So if variable is one, It'll run the…

Contents