Results 1 to 2 of 2

Thread: Optional parameters in Functions

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question Optional parameters in Functions

    How does one write optional parameters in functions and sub.?

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Fishburn
    Posts
    45
    Use the OPTIONAL keyword in the argument list, for example....

    Code:
    Private Sub SomeSubRoutine(ByVal Par1 As String, Optional Par2 As Long = 0, Optional ByVal Par3 As Boolean = False)
    As with VB6, that if you make 1 argument optional, then all arguments that follow must also be optional.

    And one change from VB6, is that you must always specify the default value for the optional argument.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width