I want to trim string before colon (including 'colon') and send to listbox, so i can calculate all prices for items.
So plz tell me how can i do that.
Thanks
use this
Code:
String data = "Processor:12000";
String result = data.substring(data.lastIndexOf(":")+1);
we substring the String. String.substring([b[This is the Start Index[/b])
so data.lastIndexOf(":") -> return the index of last : found in the string..
and return ":12000" but we need only "12000" so +1 for the index
update:
sorry i dont see that you want to calculate. so
try this code instead
Code:
int total=0;
foreach (String text in [your list].Items) {
total+= int32.Parse(text.Substring(text.LastIndexOf(":")+1));
}
Last edited by Neolitz; March 17th, 2012 at 01:13 AM.
so now my problem is when i hit ">" button for add only selected item, all items of combobox trim and tranfer to listbox.
this code works for all item button(>>) button but not for selected item(">")
so now my problem is when i hit ">" button for add only selected item, all items of combobox trim and tranfer to listbox.
this code works for all item button(>>) button but not for selected item(">")
please help me.
the foreach will work with >>
now for the > try to do this
instead of do it to all data in the combo box we will do to the item selected and insert it to the list
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.