Optional parameters in a VB.net function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Do

    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,

    Do


  • Kevin Spencer

    #2
    Re: Optional parameters in a VB.net function

    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

    Big Things are made up of
    Lots of Little Things.

    "Do" <doduong1214121 4@hotmail.com> wrote in message
    news:eTphnS7kDH A.1656@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi:
    >
    > What's the syntax for an optional parameter in my function? I've done[/color]
    so[color=blue]
    > 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
    >
    >[/color]


    Comment

    Working...