|
-
May 19th, 2005, 01:53 AM
#1
Thread Starter
Hyperactive Member
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..
-
May 19th, 2005, 02:00 AM
#2
Fanatic Member
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
-
May 19th, 2005, 02:03 AM
#3
Thread Starter
Hyperactive Member
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.
-
May 19th, 2005, 02:04 AM
#4
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
-
May 19th, 2005, 02:29 AM
#5
Thread Starter
Hyperactive Member
Re: adding values of a list box..
thats really good idea..
thanx pradeep..
Anu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|