VBNet Datum Vergleichen

Derzeit habe ich diesen code.

Dim iCurrentDate As Date = Now
Dim iStartDate As Date = CDate(dtFrom.Text)
Dim iEndDate As Date = CDate(dtTo.Text)

If (iCurrentDate > iStartDate) And (iCurrentDate < iEndDate) Then
    Console.WriteLine("Current date is within the range.")
    'Other Codes here
Else
    Console.WriteLine("Current date is in the range.")
    'Other Codes here
End If

ODER

Dim iObj As Object = IIf((iCurrentDate > iStartDate) And (iCurrentDate < iEndDate), "Current date is within the range.", "Current date is in the range.")
Console.WriteLine(iObj.ToString)
'Other Codes here

Gibt es Ersatz im obigen code? Wie BETWEEN in sql-Abfragen?

InformationsquelleAutor John Woo | 2012-01-05
Schreibe einen Kommentar