D davidkclam New Member Licensed User Longtime User Apr 22, 2010 #1 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.
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.
agraham Expert Licensed User Longtime User Apr 22, 2010 #2 I'm afraid your syntax is wrong. StrReplace does not alter the existing string, it returns a new one. You need to assign the return value tstr = StrReplace (tstr, "f","x")
I'm afraid your syntax is wrong. StrReplace does not alter the existing string, it returns a new one. You need to assign the return value tstr = StrReplace (tstr, "f","x")
S sitajony Active Member Licensed User Apr 22, 2010 #3 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...
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...