如何为可选参数分配默认的“日期时间(现在)”值。
将now对象分配给以下可选参数时,会引发错误
Constant expression is required
代码:
Public Sub ReminderMail(Optional ByVal ReminderMailDate As DateTime = Now)
// Code Block
End Sub
最佳答案
尝试这个 :
Public Sub ReminderMail(Optional ByVal ReminderMailDate As DateTime = Nothing)
If ReminderMailDate = Nothing Then ReminderMailDate = Now
// Code Block
End Sub