Page 1 of 1

str replace function that works in fbs

Posted: Sat May 23, 2020 3:57 pm
by owen

Code: Select all

Declare Function str_replace(replace_this As String, with_this As String, in_this As String) As String

Function str_replace(replace_this As String, with_this As String, in_this As String) As String
	Dim As Integer x, lort
	Dim As String new_string
	lort = Len(replace_this)
	x = InStr(in_this, replace_this)
	Do While x <> 0
		new_string = Left(in_this, x-1)
		new_string += with_this
		in_this = new_string + Mid(in_this, x + lort)
		x = InStr(in_this, replace_this)
	Loop
	Return in_this
End Function
Dim As String a, b, c, r
a="a"
b="f"
c="abcabcabc"
r=str_replace(a,b,c)
Print r
Sleep
'returns fbcfbcfbc