|
-
Feb 10th, 2008, 09:14 AM
#1
Thread Starter
Frenzied Member
-
Feb 10th, 2008, 09:40 AM
#2
Re: How to sum this value?
Item (if this applies) + subitem1 + subitem2 = total_sum
-
Feb 10th, 2008, 09:52 AM
#3
Frenzied Member
Re: How to sum this value?
If it's for each column wouldn't it be:
Listview.SubItem(1) + Listview.SubItem(2) = Total_Sum
-
Feb 10th, 2008, 10:26 AM
#4
Re: How to sum this value?
I wasn't presenting syntax - only logic that's behind it. 
If someone's managed to load listview in the first place then he/she should be able to figure the correct syntax on their own.
Wouldn't you agree?
-
Feb 10th, 2008, 10:28 AM
#5
Frenzied Member
Re: How to sum this value?
 Originally Posted by RhinoBull
I wasn't presenting syntax - only logic that's behind it. 
I do take things literally sometimes and I know how easily I get confused
-
Feb 10th, 2008, 10:30 AM
#6
Re: How to sum this value?
 Originally Posted by aikidokid
... I know how easily I get confused 
It happends.
-
Feb 10th, 2008, 07:05 PM
#7
Thread Starter
Frenzied Member
Re: How to sum this value?
The number of records is not limit only two records, How to sum the first records untill and the end of the records as I don't know the number of records exist in the listview
-
Feb 10th, 2008, 07:17 PM
#8
Re: How to sum this value?
You'll have to loop through all columns and add each column's value to some variable. Then assign that total value to perhaps last column in your listview control.
Code:
Private Sub Command1_Click()
Dim itm As MSComctlLib.ListItem
Dim subtotal As Single
Dim i As Integer
For Each itm In ListView1.ListItems
subtotal = Val(itm.Text) '<<< comment this if you don't need to calculate value of the item itself
For i = 1 To itm.ListSubItems.Count - 1
subtotal = subtotal + Val(itm.ListSubItems(i).Text)
Next i
itm.ListSubItems(itm.ListSubItems.Count).Text = susbtotal
subtotal = 0
Next itm
End Sub
-
Feb 13th, 2008, 02:01 PM
#9
Thread Starter
Frenzied Member
Re: How to sum this value?
What the used of this code ?
Only certain column I want to sum the value. I would like to sum each listitems for column1 and column 2
Code:
Private Sub Command1_Click()
Dim itm As MSComctlLib.ListItem
Dim subtotal As Single
Dim i As Integer
For Each itm In ListView1.ListItems
subtotal = Val(itm.Text) '<<< comment this if you don't need to calculate value of the item itself
For i = 1 To itm.ListSubItems.Count - 1
subtotal = subtotal + Val(itm.ListSubItems(i).Text)
Next i
itm.ListSubItems(itm.ListSubItems.Count).Text = susbtotal
subtotal = 0
Next itm
End Sub
-
Feb 13th, 2008, 02:22 PM
#10
Re: How to sum this value?
In one of my projects, I need to do two columns. Here is my code for that
Code:
For i = 1 To lvwIssues.ListItems.Count
'estimated impact amount
glngEstImpAmt = glngEstImpAmt + Val(lvwIssues.ListItems(i).SubItems(3))
'acutal impact amount
glngActImpAmt = glngActImpAmt + Val(lvwIssues.ListItems(i).SubItems(4))
'Debug.Print lvwIssues.ListItems(i).SubItems(4)
Next
-
Feb 13th, 2008, 02:41 PM
#11
-
Feb 13th, 2008, 07:27 PM
#12
Thread Starter
Frenzied Member
Re: [RESOLVED] How to sum this value?
Thank you, that great 1
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
|