Optional parameters in a VB.net function

Discussion in 'ASP .Net' started by Do, Oct 16, 2003.

  1. Do

    Do Guest

    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
    Do, Oct 16, 2003
    #1
    1. Advertising

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

    "Do" <> wrote in message
    news:...
    > 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, Oct 16, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hanover

    SQLCommand with Optional Parameters?

    Hanover, Sep 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,452
    rviray
    Sep 28, 2005
  2. Joerg Toellner
    Replies:
    4
    Views:
    1,144
    Joerg Toellner
    Jul 16, 2003
  3. Programmer

    Optional Parameters in Functions

    Programmer, Aug 20, 2003, in forum: C++
    Replies:
    2
    Views:
    11,928
    Alan Sung
    Aug 20, 2003
  4. Replies:
    1
    Views:
    536
    Chris \( Val \)
    Dec 9, 2003
  5. Bo Peng
    Replies:
    7
    Views:
    430
    tom_usenet
    Jul 7, 2004
Loading...

Share This Page