How do I properly exit a recursive function and return a value in VBA?
I have this simple code to remove multiple spaces from a string:
Public Function RemoveMultipleSpaces(s As String) As String
If InStr(1, s, " ", vbTextCompare) > 0 Then
Dim newS As String
newS = Replace(s, " ", " ")
RemoveMultipleSpaces (newS)
Else
RemoveMultipleSpaces = s
End
End If
End Function
But depending on what I use to exit either End or Exit Function, I either get nothing returned or an empty string.