Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

3.3 If/Then Selection Structure

In a program, a selection structure chooses among alternative courses of action. For example, suppose that the passing grade on an examination is 60 (out of 100). Then the Visual Basic .NET code

If studentGrade >= 60 Then
    Console.WriteLine("Passed")
End If 

determines whether the condition studentGrade>=60 is true or false. If the condition is true, then "Passed" is printed, and the next statement in order is "performed." If the condition is false, the Console.WriteLine statement is ignored, and the next statement in order is performed. A decision can be made on any expression that evaluates to a value of Visual Basic's Boolean type (i.e., any expression that evaluates to True or False).

  • + Share This
  • 🔖 Save To Your Account