Find and replace one string with another.
Find and replace one string with another.
Rate Find and replace one string with another.
(3(3 Vote))
tmpString1 = SourceString
Do Until vFixed
tmpString2 = tmpString1
tmpString1 = ReplaceFirstInstance(tmpString1, SearchString,ReplaceString)
If tmpString1 = tmpString2 Then vFixed = True
Loop
FindReplace = tmpString1
End Function
Function ReplaceFirstInstance(SourceString, SearchString, ReplaceString)
FoundLoc = InStr(1, SourceString, SearchString)
If FoundLoc <> 0 Then
ReplaceFirstInstance = Left(SourceString, FoundLoc - 1) & _
ReplaceString & Right(SourceString, _
Len(SourceString) - (FoundLoc - 1) - Len(SearchString))
Else
ReplaceFirstInstance = SourceString
End If
End Function
Find and replace one string with another. Comments
No comments yet — be the first to post one!
Post a Comment