Home > Articles > Programming > Windows Programming

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

3.4 If/Then/Else Selection Structure

The If/Then selection structure performs an indicated action only when the condition evaluates to true; otherwise, the action is skipped. The If/ThenElse / selection structure allows the programmer to specify that a different action be performed when the condition is true than that performed when the condition is false. For example, the statement

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

prints "Passed" if the student's grade is greater than or equal to 60 and prints "Failed" if the student's grade is less than 60. In either case, after printing occurs, the next statement in sequence is "performed."

  • + Share This
  • 🔖 Save To Your Account