【发布时间】:2026-01-08 06:15:01
【问题描述】:
假设 exp.Row.IsdeliveryDateNull() 返回 True。
拥有此代码:
Dim theDate As Date?
If exp.Row.IsdeliveryDateNull() Then
theDate = Nothing
Else
theDate = exp.Row.deliveryDate
End If
' Result: theDate = Nothing
theDate = If(exp.Row.IsdeliveryDateNull(), Nothing, exp.Row.deliveryDate)
' Result: theDate = is #1/1/0001 12:00:00 AM# (Default value of Date)
为什么 theDate 会根据 if 的类型(普通或内联)获得不同的值?
我期待theDate = Nothing 两种方式。
【问题讨论】:
-
您在上面提供的代码对我来说看起来不错。请提供minimal reproducible example
-
如果您将内联版本中的
Nothing更改为DirectCast(Nothing, Date?),它会做您想要的吗?否则,请告诉我们你得到了什么值。 -
对不起@Igor,我以为会很清楚。
-
@VisualVincent,除此之外,人们希望能够帮助执行网站的重复政策,但要回答这个问题。如果可以链接到他们以前的答案之一,那就更好了。