About This Code
Brief Description:
Very Very Short Lsreplacesubstring
Contributor:
Andrew Jones
Last Modified:
17 Jun 2002
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Function ReplaceSubstring(orgStr, subStr, newStr)
If Instr(OrgStr, SubStr)<=0 Then Exit Function
ReplaceSubstring=Mid(OrgStr, 1, Instr(OrgStr, SubStr)-1) & newStr &
Mid(orgStr, Instr(OrgStr, SubStr)+Len(subStr))
End Function
Usage / Example
Comments
Posted by Ricardo L Silva on 12/26/2002 07:34:06 AMSeems incomplete
Don't you think your code is a bit incomplete?
It replaces only the first occurence of the text informed.
My suggestion is to make a loop, using a temporary variable that holds the latest version of the
string after the changes made in each iteration.
Posted by Alan Bell on 04/17/2003 05:19:46 AMno, it is recursive.
Posted by Alan Bell on 07/03/2003 09:12:03 AMno, it is recursive.