Hi there!
I'd like to call a sub that has some optional and non-optional arguments.
I tried using "Named Parameters" as below:
THE CALLING SUB
Private Sub CommandButton1_Click()
Dim k As Object
Dim l As String
Dim s, b As String
s = "Mark"
b = "Brion"
Set k = CreateObject("Project1.Class1"
l = k.test_this(s, last_name:=b)
Debug.Print l
End Sub
THE FUNCTION WITH OPTIONAL ARGS:
Public Function test_this(first_name As String, Optional last_name As String)
test_this = first_name & " ^ " & last_name
End Function
I keep getting a type mismatched error..
Are "Named Arguments" the only way of calling sub/functions with optional args?
Thanks so much!
I'd like to call a sub that has some optional and non-optional arguments.
I tried using "Named Parameters" as below:
THE CALLING SUB
Private Sub CommandButton1_Click()
Dim k As Object
Dim l As String
Dim s, b As String
s = "Mark"
b = "Brion"
Set k = CreateObject("Project1.Class1"
l = k.test_this(s, last_name:=b)
Debug.Print l
End Sub
THE FUNCTION WITH OPTIONAL ARGS:
Public Function test_this(first_name As String, Optional last_name As String)
test_this = first_name & " ^ " & last_name
End Function
I keep getting a type mismatched error..
Are "Named Arguments" the only way of calling sub/functions with optional args?
Thanks so much!