日期函数中的可选参数 [英] Optional parameter in Date Function
问题描述
有没有人知道在以下函数中
可选参数应该使用什么参数而不是Date = 0?
公共函数dhAge(ByVal dtmBD As Date,可选ByVal dtmDate As Date =
0)As short
Does anyone know what parameter should be used instead of Date = 0 for the
optional parameter in the following function?
Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date =
0) As Short
推荐答案
" John Morgan" < J。****** @ premsoftware.com> schrieb
"John Morgan" <j.******@premsoftware.com> schrieb
有没有人知道应该使用什么参数代替Date = 0
以下函数中的可选参数?
公共函数dhAge(ByVal dtmBD As Date,Optional ByVal dtmDate As
Date = 0)As short
Does anyone know what parameter should be used instead of Date = 0
for the optional parameter in the following function?
Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As
Date = 0) As Short
当dtmDate未通过时,哪个日期应该是默认值?零是
不是约会。
您也可以考虑编写一个重载版本。
-
Armin
http:// www .plig.net / nnq / nquote.html
http://www.netmeister.org/news/learn2quote.html
Which date should be the default value when dtmDate is not passed? Zero is
not a date.
You might also consider writing an overloaded version instead.
--
Armin
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
公共功能dhAge(ByVal dtmBD作为日期,可选ByVal dtmDate由于日期=
0)简短
Dim intAge As Short
如果dtmDate = System.DateTime。 FromOADate(0)然后
''来电者是否通过约会?如果没有,请使用
''当前日期。
dtmDate =今天
结束如果
intAge = DateDiff(Microsoft.VisualBasic.DateInterval.Year,dtmBD,dtmDate)
如果dtmDate< DateSerial(年(dtmDate),月(dtmBD),日(dtmBD))然后
intAge = intAge - 1
结束如果
dhAge = intAge
返回dhAge
结束功能
---这与vb6中的工作原理
" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道
news:#
Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date =
0) As Short
Dim intAge As Short
If dtmDate = System.DateTime.FromOADate(0) Then
'' Did the caller pass in a date? If not, use
'' the current date.
dtmDate = Today
End If
intAge = DateDiff(Microsoft.VisualBasic.DateInterval.Year, dtmBD, dtmDate)
If dtmDate < DateSerial(Year(dtmDate), Month(dtmBD), Day(dtmBD)) Then
intAge = intAge - 1
End If
dhAge = intAge
Return dhAge
End Function
--- This works as is in vb6
"Armin Zingler" <az*******@freenet.de> wrote in message
news:#
************** @ tk2msftngp13.phx.gbl ...
**************@tk2msftngp13.phx.gbl...
" John Morgan" < J。****** @ premsoftware.com> schrieb
"John Morgan" <j.******@premsoftware.com> schrieb
有没有人知道应该使用什么参数代替Date = 0
以下函数中的可选参数?
公共函数dhAge(ByVal dtmBD As日期,可选ByVal dtmDate As
Date = 0)As short
Does anyone know what parameter should be used instead of Date = 0
for the optional parameter in the following function?
Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As
Date = 0) As Short
当dtmDate未通过时,哪个日期应该是默认值? Zero不是约会对象。
您也可以考虑编写一个重载版本。
-
Armin
> http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/ learn2quote.html
这篇关于日期函数中的可选参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!