Passing function as parameter of another function
Sub transliterate()
somecode
...
...
...
return word(a,b)
End Sub
sub word(x,y)
end sub
VBA does not use return
to pass back the result of a Function. VBA uses the following kind of construct, where the result is assigned to the function name. When End Function
is reached the value assigned to the function's name is returned.
Sub testTransliterate()
Dim a As String, b As String, Result As String
a = "one"
b = "two"
Result = transliterate(x(a), b)
Debug.Print Result
End Sub
Function x(a As String) As String
x = a & " test"
End Function
Function transliterate(x, y) As String
Dim Result As String
Result = y & ", " & x
transliterate = Result
End Function