How do I set a nullable DateTime to null in VB.NET?

后端 未结 5 1184
有刺的猬
有刺的猬 2020-12-10 11:58

I am trying to set up a date range filter on my UI, with checkboxes to say whether a DateTimePicker\'s value should be used, e.g.

Dim fromDate As DateTime? =         


        
5条回答
  •  伪装坚强ぢ
    2020-12-10 12:27

    Use New Date as a magic number:

    Dim fromDate As New Date
    If fromDatePicker.Checked Then
      fromDate = fromDatePicker.Value
    End If
    If fromDate <> New Date Then
      list = list.Where(Function(i) i.InvDate.Value >= fromDate.Value)
    End If
    

提交回复
热议问题