PDA

Click to See Complete Forum and Search --> : Fishing for more info... Optional Arguments


Mindcrime
Mar 10th, 2002, 02:35 AM
I have read that passing Optional Arguments now need to contain a default value.

Can the default value be Empty, Null etc?

Sub foo(Optional ByVal y As Integer = Null)

Serge
Mar 11th, 2002, 07:55 AM
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.

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.