jaksel
Member
- Joined
- Sep 3, 2008
- Messages
- 9
- Programming Experience
- Beginner
I have a program that involves two dates. Date1, Date2 as follows:
Dim Date1 as Date
Dim Date2 as Date
as it turns out, it is also possible that Date1 could equal "NA" (I read the date from MS Project).
So, the following two sets of statements should produce the same result:
IF ((Date1 <> "NA") And (Date1 <= Date2)) Then
'Do Something
End If
The above code does not work. But this code does:
If Date1<>"NA" Then
If Date1<=Date2 Then
'Do Something
End If
End If
Can someone explain the error in my logic? My understanding is that it will test the first condition of the "And" ... if that condition fails it will leave the IF uncompleted becuase there is no sense to make the second test.
Dim Date1 as Date
Dim Date2 as Date
as it turns out, it is also possible that Date1 could equal "NA" (I read the date from MS Project).
So, the following two sets of statements should produce the same result:
IF ((Date1 <> "NA") And (Date1 <= Date2)) Then
'Do Something
End If
The above code does not work. But this code does:
If Date1<>"NA" Then
If Date1<=Date2 Then
'Do Something
End If
End If
Can someone explain the error in my logic? My understanding is that it will test the first condition of the "And" ... if that condition fails it will leave the IF uncompleted becuase there is no sense to make the second test.