Search code examples
vb.netoperators

Why does "ELSE : " compile in vb.net?


Why does this compile?

If Months > 1 Then

    Label.Text = Months + " Months"

Else : Months = 1

    Label.Text = Months + " Month"

End If

Using Visual Studio 2010.


Solution

  • : is a statement separator. It's equivalent to a newline:

    If Months > 1 Then
    
        Label.Text = Months + " Months"
    
    Else
    
        Months = 1
        Label.Text = Months + " Month"
    
    End If