Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How I can sum all value that shows the size of the files in listbox1?
Give me some examples.
Thank You.
Posted
Updated 24-Aug-13 8:38am
v2

1 solution

VB
Dim total as Int
For l_index As Integer = 0 To listbox1.Items.Count - 1
    total  = total + Convert.toInt32(listbox1.Items(l_index))
Next
 
Share this answer
 
Comments
Pouya Mozafar 24-Aug-13 14:51pm    
What is dim total as int?
Is int ,integer?
If it is integer this error shows for " total = total + Convert.toInt32(listbox1.Items(l_index))"
Error:
Input string was not in a correct format.
Mahesh Bailwal 25-Aug-13 1:33am    
Sorry, It should be Integer instead of Int.
About other problem your facing, in the question you have mentioned "sum all value that shows the size of the files in listbox1" based on that I provided solution best to my knowledge.Too to get correct answer you must provide all the information in the question including code snippet, other wise answers are given on assumption which may not be right.

Please click on "Improve question" link and update your question with relevant information.
ledtech3 25-Aug-13 0:01am    
you seem to be missing some information from your question.

Your question reads to me that you are getting a list of file with the size of them output into a listbox.

Answer #1 is attempting to give you a total amount of items in your listbox but not sure why they are tying it that way.

To get the number of items in a listbox just do.
Dim TotalItems As Integer
TotalItems = ListBox1.Items.Count
Label1.Text = TotalItems.ToString
Pouya Mozafar 25-Aug-13 3:07am    
How I can sum the size of 4 or more items in list box?
I need the total size of the listbox1.items .
Mahesh Bailwal 25-Aug-13 3:18am    
please provide example of what your listbox contains.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900