0

Here's the simplest way. This calculates the sum of the fourth column

```
Dim TotalSum As Double = 0
Dim TempNode As ListViewItem
For Each TempNode In ListView1.Items
TotalSum += CDbl(TempNode.SubItems.Item(3).Text)
Next
MsgBox(TotalSum) ' Debug
```

and it assumes that each item is a valid number.

A bit safer solutions uses TryParse to check validity:

```
Dim TotalSum As Double = 0
Dim TempNode As ListViewItem
Dim TempDbl As Double
For Each TempNode In ListView1.Items
If Double.TryParse(TempNode.SubItems.Item(3).Text, TempDbl) Then
TotalSum += TempDbl
End If
Next
MsgBox(TotalSum)
```

and again calculates the sum of the fourth column.

HTH

Question Answered as of 4 Years Ago by Teme64

Reputation Points: 0 [?]

Q&As Helped to Solve: 0 [?]

Skill Endorsements: 0 [?]

•Unverified Member

Reputation Points: 0 [?]

Q&As Helped to Solve: 0 [?]

Skill Endorsements: 0 [?]

•Unverified Member

Reputation Points: 0 [?]

Q&As Helped to Solve: 0 [?]

Skill Endorsements: 0 [?]

•Unverified Member

0

What if, "I would like to create a query statement that would give me the sum of the column(total_bill)?"

like this:

("Select SUM(total_bill)FROM tbl_estimates WHERE estimation_date = '"& Textbox1.Text & "'",2)

I would like to Displat it in my listview.

My, Query statement is absolutely right, but then there is still an error that doesnt have a suggestion.

Maybe you guys could help me..... :)

You

This question has already been solved: Start a new discussion instead