Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey

 

I'm using vb.net and I have a question about opional params.

 

if i have a sub:

 

Public sub doSomething( ..., Optional Byref d1 as Date = Nothing )

...

End Sub

 

I am getting an error saying cannot cast object to date in a constant expression. Why am I getting this? And how do I fix it to set some null default value?

  • Moderators
Posted
First I would use DateTime instead of Date, second you may want to overload the method and not use the Optional keyword. The OverLoad would solve the problem of the argument being left out.
Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...