String replace function
String replace function
Rate String replace function
(1(1 Vote))
' Function to replace a string within a string
' srchStr string is the text to look in
' forStr is the string to search for
' repStr is the string to replace any occurences of forStr
*
'
'THIS FUNCTION IS CASE SENSITIVE
'
' Example:
' MyString = Replace("Hello world!","Hello","Goodbye")
'
' This would make MyString "Goodbye world!"
'
' D.Hawkins 2002
Public Function Replace(srchStr, forStr, repStr)
If InStr(srchStr, forStr) Then
Do While InStr(srchStr, forStr)
place = InStr(srchStr, forStr)
srchStr = Mid(srchStr, 1, place - 1) & repStr & Mid(srchStr, place + Len(forStr), Len(srchStr))
Replace = srchStr
Loop
Else
Replace = srchStr
End If
End Function
String replace function Comments
No comments yet — be the first to post one!
Post a Comment