【发布时间】:2012-02-03 09:03:43
【问题描述】:
目前,我有这个代码。
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
或
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
上面的代码有什么替代品吗?就像 sql 查询中的 BETWEEN 一样?
【问题讨论】: