相关疑难解决方法(0)

如何在VB.NET中将可为空的DateTime设置为null?

我正在尝试在我的UI上设置日期范围过滤器,并带有复选框,说明是否应该使用DateTimePicker的值,例如

Dim fromDate As DateTime? = If(fromDatePicker.Checked, fromDatePicker.Value, Nothing)
Run Code Online (Sandbox Code Playgroud)

然而设置fromDateNothing不会导致设置为Nothing'12:00:00 AM',并且以下If语句错误地执行过滤器,因为startDate不是Nothing.

If (Not startDate Is Nothing) Then
    list = list.Where(Function(i) i.InvDate.Value >= startDate.Value)
End If
Run Code Online (Sandbox Code Playgroud)

我如何真正确保startDate获得价值Nothing

vb.net vb.net-2010

16
推荐指数
1
解决办法
6万
查看次数

标签 统计

vb.net ×1

vb.net-2010 ×1