Search code examples
vb.netif-statementline-breaks

I can't use the underscore (_) to break the if statement in vb.net


If T_ANAME.Text = "" Or R_MALE.Checked = False Or R_FEMALE.Checked = False Or R_OTHERS.Checked = False _

Or (C_COUNTRY.Text = "-- Select Country --") _ Then

End If

This code shows syntax error.

I referred this page too If Statement With Multiple Lines


Solution

  • Remove the extra _ at the end of the logical statement.

    If T_ANAME.Text = "" Or R_MALE.Checked = False Or R_FEMALE.Checked = False Or R_OTHERS.Checked = False _
    Or (C_COUNTRY.Text = "-- Select Country --") Then
    ' do something 
    End If