4

Decision Branching

Decision branching is a programming construct that allows a program to execute different sets of instructions based on a condition or set of requirements. There are several ways to implement decision branching in programming languages, but the most common methods include If statements, switch or Case statements, and ternary operators.

In this chapter, we’re going to cover the following main topics:

  • If statements
  • Case statements
  • Ternary operators
  • VB.NET OrElse operator
  • VB.NET AndAlso operator

If statements

In Visual Basic, the If statement executes a block of code if a condition is true. The basic syntax of an If statement in Visual Basic is as follows:

 If condition Then    ' code to execute if condition is true End I ...

Get Visual Basic Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.