LCKB
Count of characters - Printable Version

+- LCKB (https://lckb.dev/forum)
+-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109)
+--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196)
+---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192)
+---- Thread: Count of characters (/showthread.php?tid=2217)



- soryjero - 07-19-2013


i am trying to execute a db update but when i try it, i get an error because name looks like this

 

Manual for making Heros necklace

so the problem is that appear so much . then i have coded this to execute command:

 

 

if (items.description.Contains(" "))
                    {
                        sb.Append(items[i].description);[/i]
[i]                        indice = items[/i][i][i].description.IndexOf(" ");[/i][/i]
[i][i]                        sb.Insert(indice, \\);[/i][/i]
[i][i]                        items[/i][/i][i][i][i].description = sb.ToString();[/i][/i][/i]
[i][i][i]                    }  [/i][/i][/i]
[i][i][i]                    record = ...[/i][/i][/i]

[i][i][i]and this looks like this:[/i][/i][/i]

[i][i][i] [/i][/i][/i]

[i][i][i]Manual for making Hero\s necklace[/i][/i][/i]

[i][i][i]so that is what i wanted but when name has more than one i still have problems, so i would like you help me knowing how to code this to test how much are there and then, inset a \ before all .[/i][/i][/i]

[i][i][i] [/i][/i][/i]

[i][i][i]thanks in advance.[/i][/i][/i]




- someone - 07-20-2013


Try to use replace instead:

if (items[i].description.Contains("")){
items[i].description = items[i].description.Replace("", @"\");
}

Or you could simply put this(without checking if contains, because if there are none it will put none):

items[i].description = items[i].description.Replace("", @"\");




- soryjero - 07-20-2013


it works perfectly someone.

 

thanks so much Smile




- Nymphetamine - 07-20-2013


Mark the topics tag as SOLVED if the issue is solved.

Thanks




- soryjero - 07-20-2013



Mark the topics tag as SOLVED if the issue is solved.

Thanks

 

sorry, i forgot to do it.

 

thanks.




- Nymphetamine - 07-20-2013

Thank you