Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constant expression is required error message 1

Status
Not open for further replies.

PsychoCoder

Programmer
May 31, 2006
140
US
I have a function Im creating:
Code:
Public Shared Function GetErrors(ByVal lbl As Label, Optional ByVal type As Integer = 1, Optional ByVal dDate As DateTime = DateTime.Today.ToShortDateString, Optional ByVal eType As Integer = 1, Optional ByVal status As Integer = 1)

The DateTime.Today.ToShortDateString for the default value of the Optional parameter is telling me "Constant expression is required". Im trying to use the current date as the default value if the user doesnt specify one.
 
Yes, it will need a Value which is constant and the date will never be constant. Instead, try setting it to a default on Nothing and then check that in your function (and if it is still Nothing, set it to today's date).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm,

Once again thank you for the reply. Though Im not new to programming I am fairly new to .NET and am still trying to get the hang of the cool stuff .NET Offers over classic ASP 2.0 and 3.0. I generally try and research an error before I ask here, but I do read the forums daily.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top