dips at April 18th, 2007 05:23 — #1
I have some figures in a listbox and would like all the values to be added together. Any one how i would go about that?
dave_ at April 18th, 2007 05:34 — #2
No. The question is too vague.
What language/api are you using?
It's probably very easy to do, and it shows that you don't really understand how to program.
Perhaps you should look at some programming tutorials. If you're using C/C++ look up for/while loops.
int total = 0
for each item in listbox
total = total + atoi(item.value) // atoi to convert from string to integer
dips at April 18th, 2007 05:37 — #3
sorry i am using using vishual studio 2005
oisyn at April 18th, 2007 05:43 — #4
That doesn't help anything. First of all, Visual Studio represents a whole suite of different languages (C++, C#, VB.Net, ...). Secondly, you don't describe the problem at hand. What is your exact problem? Give us a detailed description and show us the code you already have. What results are you getting from that code? And what are you expecting to get?
If you can't answer these questions we can't help you. If you're just looking for someone to implement it for you you have come to the wrong place.
dave_ at April 18th, 2007 05:43 — #5
Last time I looked, visual studio supported C++, C#, J# and visual basic.
Sounds like you can't program at all. I'm afraid you're asking the wrong questions if you want to learn how to program.
dips at April 18th, 2007 05:46 — #6
i am using visual studio, vishual basic 2005. I am trying to get values from a listbox which are figures and add them together. I no i am new to this and am doing this as part of a school project. Thank you
oisyn at April 18th, 2007 05:47 — #7
I am trying to get values from a listbox which are figures and add them together
Show us your sourcecode. And of course only the relevant part, e.g., the function that needs to add the elements of the listbox together.
dips at April 18th, 2007 05:49 — #8
this is the code i am using to populate my listbox
If com1.Text = "Bond Street" Then
Dim strSql As String = "SELECT * from Feedback WHERE Attractionname = 'Bond Street'"
Dim objCommand As New System.Data.OleDb.OleDbCommand(strSql, objConnection)
Dim objReader As System.Data.OleDb.OleDbDataReader
objReader = objCommand.ExecuteReader
If objReader.HasRows Then
the items in listbox2 are all figures and i want them to be added together
oisyn at April 18th, 2007 05:54 — #9
Please put your code in [code**]...[/code] blocks
You can iterate over the items in the list with
For Each item as Object in ListBox2.Items
' what is the type of an item? You should convert it to a numerical type (such as Integer or Single) and add them to a variable.
dips at April 18th, 2007 05:58 — #10
Dont worry about it now im sure il find a way. Thanks