While I have seen many replace substring functions posted here and elsewhere I
am amazed out how complex most of them are. here is a very simple function that
performs extremely well.
Keeping it Simple is the Key to quality applications!
Function ReplaceSubString(SourceS As String, SearchS As String, ReplaceS As
String) As String
While Instr(SourceS, SearchS) > 0
SourceS = Left$(SourceS, Instr(SourceS, SearchS) - 1) + ReplaceS +
Right$(SourceS, Len(SourceS) - Instr(SourceS, SearchS) - Len(SearchS) + 1)
Wend
ReplaceSubstring = SourceS
End Function
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
This was first published in November 2000