Visual Basic .Net support the decision making using If…Then…Else statements. In addition to the simple If…Then statement, If…Then…Else provides an else part. Here we can assign two different statements one for true condition and other one for false condition.
If(condition)Then [statement true] 'statement true will be executed if the condition is true. Else [statement false] 'statement flase will be executed if the condition is false. End If
If a > b Then large = a Else large = b
Module Module1 Sub Main() Dim a = 5, b = 10, larger As Integer If a > b Then larger = a Else larger = b End If Console.WriteLine(larger) End Sub End Module
As b=10 is larger than a=5, the output of the program will be 10.