adding values of a list box..
hi ..
this buddy getting small problem with list box..
I hv a listbox which stores some values..(gets values from a table)
when ever the listbox is refreshed ,I have to add (sum) all the values which are there in the listbox and i have to show that value in a text box..
I think u ppl got my prob...is there any simple way to get it..????
plz chk it..
thanx & regards
Anu..
Re: adding values of a list box..
VB Code:
Dim i As Integer
Dim sum As Integer
For i = 0 To List1.ListCount - 1
sum = sum + CInt(List1.List(i))
Next i
Text1.Text = sum
Re: adding values of a list box..
hi rob,
Is there any direct function for this...I heared that there was a direct function that wil gives like the same..
thanx & regards
Anu.
Re: adding values of a list box..
I suggest u don't use the listbox to sync the textbox. Instead fill it directly by querying the database whenever the listbox is refreshed using query like this
SELECT SUM(FieldName) FROM TableName
That would be faster and easier than iterating through the listbox.
EDIT: u can use Connection.Execute to execute the query
Re: adding values of a list box..
thats really good idea..
thanx pradeep..
Anu.