Home

Computer Programming Branching Statements

|
Updated:  
2016-03-26 20:24:59
|
HTML & CSS Essentials For Dummies
Explore Book
Buy On Amazon

Most programming languages can make decisions based on the data you provide. Instead of performing the same tasks the same number of times, branching statements create a program that reads your data and automatically performs the tasks you need, skipping the tasks you don't need. Here are some branching commands that you'll need to know:

If (condition) Then command<br /><br />If (condition) Then
  Commands
End if
<br />If (condition) Then
  Commands
Else
  Commands
End if
<br />If (condition) Then
  Commands
Elseif (condition2) then
  Commands
End if
<br />Select Case variable
  Case value1
    Commands
  Case value2
    Commands
  Else
    Commands
End select
<br />switch (variable) {
  case value1:
    Commands;
    break;
  case value2:
    Commands;
    break;
  default:
    commands;
}

About This Article

This article is from the book: 

About the book author:

Wallace Wang specializes in making complex topics understandable. His assorted For Dummies tech books have sold nearly half a million copies. He has a master’s degree in computer science along with side hustles in stand-up comedy and screenwriting because life is too short to focus on just one thing.