Default Value for Date

  • Thread starter Thread starter Enosh Chang
  • Start date Start date
E

Enosh Chang

Hi all,

I have a question about optional parameter. If I use optional parameter, it
ask me to set default value for it. How can I set default value for Date
parameter? Thanks!

Best Regards
 
Enosh Chang said:
I have a question about optional parameter. If I use optional
parameter, it ask me to set default value for it. How can I set
default value for Date parameter? Thanks!

You can use a date literal:

....., Optional ByVal d As Date = #3/12/2003#


Alternatively you can add an overloaded procedure:

sub mysub(byval arg1 as integer)
mysub(arg1, #3/12/2003#)
end sub

sub mysub(byval arg1 as integer, byval d as date)
'code
end sub
 
* "Enosh Chang said:
I have a question about optional parameter. If I use optional parameter, it
ask me to set default value for it. How can I set default value for Date
parameter? Thanks!

\\\
Public Sub Foo(Optional ByVal Goo As Date = #10/10/2010#)
If Goo = #...# Then
...
Else
...
End If
End Sub
///

Notice that it's better to create overloaded versions of the
procedure:

\\\
Public Sub Foo()
Foo(Date.MinValue)
End Sub

Public Sub Foo(ByVal Goo As Date)
...
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Back
Top