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?
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
sorry i am using using vishual studio 2005
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.
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.
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
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.
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
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.
Dont worry about it now im sure il find a way. Thanks