If (valSDate <> Null AND valSDate <> "" AND valSDate.Length>0) Then
dteScheduled.SetDate(DateTime.DateParse(valSDate),True)
Else
dteScheduled.SetDate(-1,True)
End If
Per the debugger
valSDate
value = null
However the code still runs the first part of the if statement, instead of the else section
When you compare a string variable with another object the other object is first converted to string. The result is that you are comparing the string with "null".
And another point:
if a string is empty then it's length is always 0, if a string is not empty the length cannot be 0.
Therefore it's no need for both checks (tmpstDate = "" OR tmpstDate.Length=0), you only need one.