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)
ReplaceSubstring = SourceS
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.