“日期无所不能”失败 [英] "Date Is Nothing" fails
本文介绍了“日期无所不能”失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显然,Date类型的引用不能假定值Nothing,因为
以下代码失败:
Dim d As Date
.......其他代码......
如果d什么都没有那么
结束如果
那么对于Date类型的引用,Nothing的等价是什么?
apparently references of type Date can not assume the value Nothing, because
the following code fails:
Dim d As Date
.......other code......
If d Is Nothing Then
End If
so then what is the equivalent to Nothing for a reference of type Date ?
推荐答案
Date是值类型和值类型不能为null。想想另一种方式
来确定d变量是否已被赋予特定值。
" John A Grandy" < johnagrandy-at-yahoo.com>写在
新闻:#w ************** @ TK2MSFTNGP10.phx.gbl:
Date is a value type and value types cannot be null. Think of another way
to identify if the d variable has been given a specific value.
"John A Grandy" <johnagrandy-at-yahoo.com> wrote in
news:#w**************@TK2MSFTNGP10.phx.gbl:
显然是参考类型日期不能假设值Nothing,
因为以下代码失败:
Dim d As Date
......其他代码......
如果d什么都没有那么
结束如果
那么对于类型为Date的引用,Nothing的等价是什么?
apparently references of type Date can not assume the value Nothing,
because the following code fails:
Dim d As Date
......other code......
If d Is Nothing Then
End If
so then what is the equivalent to Nothing for a reference of type Date
?
*" John A Grandy" < johnagrandy-at-yahoo.com> scripsit:
* "John A Grandy" <johnagrandy-at-yahoo.com> scripsit:
显然,Date类型的引用不能假设值为Nothing,因为以下代码失败:
Dim d As Date
.. ....其他代码......
如果d什么都没有那么
结束如果
那么什么相当于没什么可供参考类型日期?
apparently references of type Date can not assume the value Nothing, because
the following code fails:
Dim d As Date
......other code......
If d Is Nothing Then
End If
so then what is the equivalent to Nothing for a reference of type Date ?
''DateTime''是一个所谓的值类型,而不是像
类这样的引用类型。
-
Herfried K. Wagner
MVP·VB Classic,VB.NET
< http://www.mvps.org/dotnet>
''DateTime'' is a so called "value type", not a reference type like
classes are.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
John,
正如其他人指出的那样Date是一个值类型,你从来没有真正有一个日期的
引用。除非您将日期值包装起来,将
日期放在对象参考中,但这是另一回事...
但是你可以检查是否d = Date.MinValue以查看日期是否已将
设置为某个值。
John,
As the other have pointed out Date is a value type, you never really have a
reference to a Date. Unless of course you box the date value, by placing the
date in an object reference, that however is a different matter...
You can however check to see if d = Date.MinValue to see if the date has
been set to a value yet or not.
Dim d As Date
......其他代码......
如果d = Date.MinValue那么
希望这有帮助
周杰伦
John A Grandy < johnagrandy-at-yahoo.com>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...显然类型为Date的引用不能假定值没什么,
,因为下面的代码失败了:
Dim d As Date
......其他代码......
如果d is Nothing然后
结束如果
那么对于Date类型的引用,什么是Nothing呢?
Dim d As Date
......other code......
If d = Date.MinValue Then
Hope this helps
Jay
"John A Grandy" <johnagrandy-at-yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... apparently references of type Date can not assume the value Nothing, because the following code fails:
Dim d As Date
......other code......
If d Is Nothing Then
End If
so then what is the equivalent to Nothing for a reference of type Date ?
这篇关于“日期无所不能”失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文