i'm a new in C#. I got a problem like this.
I want to obtain any selected item on ListBox. Those ListBox contain numerical value for example 5 , 10 , 12.5 , 30 ......
The problem appear when i want to convert the 12.5 into double, i alwayas got 125.0 not 12.5 it seLf. Here my code to obtain the value from the ListBox
arr variabel is an ArrayList.
Code |
thx all.

Rakesh Jha85 reputationPosted Oct 4, 2010, 8:40 PM EDT
foreach (object itemChecked in listBox1.SelectedItems)
{
arr.Add(Convert.ToDouble(itemChecked.ToString()));
}
Deepthi Aravind53 reputationPosted Oct 4, 2010, 8:51 PM EDT
Which control you are using??
Suthish NairRank #92 · 22.8K reputationPosted Oct 4, 2010, 10:19 PM EDT
Another way,
double value = double.Parse(itemChecked.ToString());
arr.Add(value);
Johan6 reputationPosted Oct 4, 2010, 11:46 PM EDT
the 12.5 still become 125.0 not 12.5 in double format.
is there any other way ?
thx.
Suthish NairRank #92 · 22.8K reputationPosted Oct 5, 2010, 12:06 AM EDT
Dim i As Integer Dim arr As New ArrayList For i = 0 To ListBox1.GetSelectedIndices.Count - 1 arr.Add(Convert.ToDouble(ListBox1.Items(ListBox1.GetSelectedIndices(i)).Value.ToString())) NextRakesh Jha85 reputationPosted Oct 5, 2010, 4:04 AM EDT
Hirendra SisodiyaRank #258 · 9.8K reputationPosted Oct 5, 2010, 5:28 AM EDT
we can use 'parse' and 'convert' method for doing it, but you are still in problem after doing same things so please check itemChecked.ToString() value .
thanks
Roy S194 reputationPosted Oct 5, 2010, 10:35 AM EDT
Gomathi PalaniswamyRank #714 · 3.3K reputationPosted Oct 5, 2010, 11:35 PM EDT
try like this
Johan6 reputationPosted Oct 6, 2010, 9:27 PM EDT
i still got no luck with it.
i cannot use comma as the separator for it.