Excel VBA宏MsgBox自动将数字转换为科学记数法,我该如何阻止它?

时间:2013-12-20 13:43:01

标签: excel vba excel-vba

我试图将当前日期设置为毫秒,以便将其与AD“LastLogon”时间戳进行比较。问题是当前日期自动变为科学记数而不是我需要的18位数字。如何强制它显示所有数字?

Dim currentDate
currentDate = Now * (8.64 * 10 ^ 11) + 109205
'MsgBox (DateAdd("d", -90, Now))
MsgBox (currentDate)

2 个答案:

答案 0 :(得分:2)

 MsgBox( Format(currentDate, "#0"))

或您喜欢的其他格式

答案 1 :(得分:0)

Dim currentDate
currentDate = Now * (8.64 * 10 ^ 11) + 109205
'MsgBox (DateAdd("d", -90, Now))
MsgBox (Format(currentDate(), "MM dd, yyy"))
MsgBox (Format(Now(), "MM dd, yyy"))

Now()显示日期 currentDate是一个过流。

How to format date in VBA?