P Pappsegull Member Licensed User Longtime User Oct 30, 2011 #1 I run a loop to insert data, it works well until I come to a name that have the ' character in it ( i.e. in Tongan Pa'anga). I have try: sA(0).Replace("'", "ʻ") , but the ' will not be replaced. sA() is a String array B4X: s = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?" [COLOR="Blue"]For[/COLOR] x = 0 [COLOR="Blue"]to[/COLOR] y sA(0) = R(x).Name: sA(0).Replace("'", "ʻ") sA(1) = R(x).Code: sA(2) = R(x).Info [COLOR="Green"]'More field to fill here...[/COLOR] DB.ExecNonQuery2("INSERT INTO Table VALUES(" & s &)", sA) [COLOR="Blue"]Next[/COLOR] Any idea? /Thanks
I run a loop to insert data, it works well until I come to a name that have the ' character in it ( i.e. in Tongan Pa'anga). I have try: sA(0).Replace("'", "ʻ") , but the ' will not be replaced. sA() is a String array B4X: s = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?" [COLOR="Blue"]For[/COLOR] x = 0 [COLOR="Blue"]to[/COLOR] y sA(0) = R(x).Name: sA(0).Replace("'", "ʻ") sA(1) = R(x).Code: sA(2) = R(x).Info [COLOR="Green"]'More field to fill here...[/COLOR] DB.ExecNonQuery2("INSERT INTO Table VALUES(" & s &)", sA) [COLOR="Blue"]Next[/COLOR] Any idea? /Thanks
NJDude Expert Licensed User Longtime User Oct 30, 2011 #2 Do this: B4X: sA(0).Replace("'", "''") That should work. Upvote 0
P Pappsegull Member Licensed User Longtime User Oct 30, 2011 #3 String.Replace() don't work at all Thanks Dude Sorry but String.Replace() don't work at all txt = txt.Replace(Target As String, Replacement As String) I have try all kind of chracters but nothing get replaced:BangHead: i.e. B4X: [COLOR="Blue"]Dim[/COLOR] s As [COLOR="Plum"]String[/COLOR]: s = "hello" s.Replace("e", "o") [COLOR="Green"]' s = "hello" here[/COLOR] Anyone any other ideas? Bug? Thanks! Upvote 0
String.Replace() don't work at all Thanks Dude Sorry but String.Replace() don't work at all txt = txt.Replace(Target As String, Replacement As String) I have try all kind of chracters but nothing get replaced:BangHead: i.e. B4X: [COLOR="Blue"]Dim[/COLOR] s As [COLOR="Plum"]String[/COLOR]: s = "hello" s.Replace("e", "o") [COLOR="Green"]' s = "hello" here[/COLOR] Anyone any other ideas? Bug? Thanks!
klaus Expert Licensed User Longtime User Oct 30, 2011 #4 Try this code B4X: Dim s, r As String s = "hello" r = s.Replace("e","o") Log (r) B4X: s = s.Replace("e","o") would work too. Best regards. Upvote 0
Try this code B4X: Dim s, r As String s = "hello" r = s.Replace("e","o") Log (r) B4X: s = s.Replace("e","o") would work too. Best regards.
agraham Expert Licensed User Longtime User Oct 30, 2011 #6 Pappsegull said: Bug? Click to expand... Strings are immutable in Java (and C#) so String functions return a new String and do not alter the existing one. You will have to assign the returned String to the existing variable if you want the effect of altering a String. Upvote 0
Pappsegull said: Bug? Click to expand... Strings are immutable in Java (and C#) so String functions return a new String and do not alter the existing one. You will have to assign the returned String to the existing variable if you want the effect of altering a String.
P Pappsegull Member Licensed User Longtime User Oct 30, 2011 #7 Thanks! Okey, I understand now Upvote 0