Optional parameters in a VB.net function

D

Do

Hi:

What's the syntax for an optional parameter in my function? I've done so
many ASP 3.0 Web Classes that
I haven't experienced the "Optional" parameter.

Eg. Public function adduser(ByVal firstname as String, ByVal Lastname as
String)

End Function

If I want the lastname to be optional, what is the syntax?

Thanks,

Do
 
K

Kevin Spencer

Public function adduser(ByVal firstname as String, Optional ByVal Lastname
as String = "")

Remember that when you declare a parameter as optional that you must assign
a default value to it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top