Nate Pet
Nate Pet

Reputation: 46222

VB.NET Expression Expected

When I do the following I get a message saying Expression Expected

     If (Not (String.IsNullOrEmpty(e.Item.DataItem("DueDate")) && String.IsNullOrEmpty(e.Item.DataItem("ActualDate"))) ) Then


     End If

Upvotes: 1

Views: 189

Answers (2)

Steve
Steve

Reputation: 216293

If this is VB.NET then the AND operator is AndAlso

AndAlso and it's brother OrElse are better because:

  • Avoids executing part of a logical expression to avoid problems.
  • Code optimization by not executing any more of a compound expression than required

So your code should be

If (Not (String.IsNullOrEmpty(e.Item.DataItem("DueDate")) AndAlso String.IsNullOrEmpty(e.Item.DataItem("ActualDate"))) ) Then 

    .... 
End If 

Upvotes: 1

suff trek
suff trek

Reputation: 39777

Instead of && use AndAlso

Upvotes: 1

Related Questions