LotusScript @ReplaceSubstring Equivalent (Updated)

Mindwatering Incorporated

Author: Tripp W Black

Created: 07/11/2003 at 10:47 AM

 

Category:
Notes Developer Tips
LotusScript

The following code will replace characters in a string with a replacement string similar to @ReplaceString formula.
It also supports multiple characters for the search string (the substring part to be replaced)
code.txt


Alternate:
Function StrReplaceSlashes(startStr As String, replaceChr As String, newChr As String) As String
Dim newStr As String

On Error GoTo FErrorHandler

newStr = startStr
If (replaceChr = "") Then
StrReplaceSlashes = startStr
End If
Do While InStr(newStr, replaceChr) > 0
newStr = Left$(newStr, InStr(newStr, replaceChr)-1) + newChr + Right$(newStr,Len(newStr)-Instr(newStr, replaceChr))
Loop
StrReplaceSlashes = newStr

FExit:
Exit Function

FErrorHandler:
StrReplaceSlashes = startStr
Resume FExit
End Function


previous page