Friday, March 16, 2012

Optional parameters in a VB.net function

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,

DoPublic 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.

"Do" <doduong12141214@.hotmail.com> wrote in message
news:eTphnS7kDHA.1656@.tk2msftngp13.phx.gbl...
> 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

0 comments:

Post a Comment