Private Sub Replace(sOriginal As String, sReplaceFrom _
As String, sReplaceTo As String)
'Useful routine for string replacement
Dim sBuffer As String
Dim iPos As Long
'Initialization
iPos = 1
Do While iPos > 0
iPos = InStr(1, sOriginal, sReplaceFrom, 1)
If iPos > 0 Then 'sReplaceFrom found
sBuffer = sBuffer & Left (sOriginal, iPos - 1) & _
sReplaceTo
sOriginal = Mid(sOriginal, iPos + Len(sReplaceFrom))
Else
sBuffer = sBuffer & sOriginal
End If
Loop
sOriginal = sBuffer
End Sub
|