For reasons I'd rather like to not talk about, I am in a VBA environment that doesn't have the replace function (Access 97). I have wrote this to alleviate my frustrations.
My question is, what is the quickest and most efficient way of writing this function? I am not married to it, I just want the best possible piece of code. While I do enjoy readability I am also OK with stepping away from that to learn something super cool.
Public Function RepStr(InputString As String, InvalidStr As String, ValidStr As String) As String Dim ModString As String ModString = InputString While InStr(1, ModString, InvalidStr) > 0 ModString = Left(ModString, InStr(1, ModString, InvalidStr) - 1) & _ ValidStr & Mid(ModString, Len(InvalidStr) + InStr(1, ModString, InvalidStr)) Wend RepStr = ModString End Function