Results 1 to 2 of 2

Thread: Fishing for more info... Optional Arguments

  1. #1

    Thread Starter
    Fanatic Member Mindcrime's Avatar
    Join Date
    Jun 2001
    Location
    Peterborough, UK
    Posts
    555

    Fishing for more info... Optional Arguments

    I have read that passing Optional Arguments now need to contain a default value.

    Can the default value be Empty, Null etc?
    Code:
    Sub foo(Optional ByVal y As Integer = Null)
    Mindcrime : )
    ICQ 24003332

    VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Yes, you can still use Optional Parameters, but you have to specify the default value. This is required because IsMissing function is no longer supported.
    VB Code:
    1. Public Function MyFunct(Optional MyParam As Integer = -1) As Boolean
    You can also achieve this by using function overload. I personally like function overload better then optional parameters.
    Actually, the only reason Optional Parameters existed in previous versions of VB is because there was no function overload feature.

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