-1
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

Community
  • 1
  • 1
Udhaya
  • 121
  • 1
  • 14
  • Perhaps you should remove the latest underscore, the one just before Then? – Steve Nov 22 '16 at 14:09
  • VBA (in the linked post) is not VB.NET. In VB.NET you can break after any of the `Or` or `And` keywords without the underscore unless your VS is very very old (those should be `OrElse`) – Ňɏssa Pøngjǣrdenlarp Nov 22 '16 at 14:09
  • Bad example to follow since you are using `VB.NET` and not `VBA` however remove the underscore before the `Then`. And backspace your `Or` line so it's right under the `If` line. Can't be a gap. – Bugs Nov 22 '16 at 14:12
  • And consider to use OrElse instead of Or. Just test for true one of the conditions is enough See: http://stackoverflow.com/questions/1170754/or-versus-orelse – Steve Nov 22 '16 at 14:15

1 Answers1

2

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
AncientYouth
  • 471
  • 1
  • 4
  • 12