View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
OfficeHacker OfficeHacker is offline
external usenet poster
 
Posts: 14
Default overloading a function

Remember also that IsMissing only works if the optional argument is a Variant.
If the argument is a string you can check the length of the string to
determine if
it has been pased like this:

If Len(StringArgument) = 0 then

end if


"Jake Marx" wrote:

Hi Gixxer,

Not really. You can use optional arguments to simulate overloading:

Public Sub myfunc(Optional a As Variant, Optional b As Variant)
If IsMissing(a) Then
Debug.Print "a not passed"
Else
Debug.Print "a = " & CStr(a)
End If

If IsMissing(b) Then
Debug.Print "b not passed"
Else
Debug.Print "b = " & CStr(b)
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Gixxer_J_97 wrote:
is there a way to overload a function in vba?
ie
public sub myfunc(a, as integer, b as integer)
end sub

and

private sub myfunc()
end sub

where the private sub is used for the 'local' userform - and the
public sub is called by an outside module (where a and b would be the
arguments that would normally be accessed by the userform, but in
this case need to be passed)

?