strreplace cannot work

davidkclam

New Member
Licensed User
Longtime User
Dear Sir

I have tried to use strreplace in v.6.9.

My code :

tstr = "asdfsdfsdfdf sdfsdf"
StrReplace (tstr, "f","x")
Msgbox(tstr)

According to help, the result should be "asdxsdxsdxdx sdxsdx".
Unfortunity the result is no change "asdfsdfsdfdf sdfsdf".

Pls advice me how to solve it.
 

sitajony

Active Member
Licensed User
The replace function return the new string and does'nt replace the string himself...
In first parametter it's the String wich contain the old value and the new value... This function can also used like this:
B4X:
[color=red]StrReplace("Texte","xte","xt")[/color]
"Texte" it's not a variable... So you must write
B4X:
[color=green]newtext=StrReplace("Texte","xte","xt")[/color]
and newtext will get the new string (Text)...
You can also write:
B4X:
[color=green]TextBox1.Text=StrReplace("Texte","xte","xt")[/color]
On the Help File you'll view somes examples and more informations ;)

Good Luck...
 
Top