# Calculate the total of first column in datagrid

Page 1 of 1

## 1 Replies - 8423 Views - Last Post: 05 October 2012 - 09:38 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=294409&amp;s=ffbe210dfd5e4f70126d62fb21f7bd6a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 raelkun00

Reputation: 1
• Posts: 99
• Joined: 01-October 12

# Calculate the total of first column in datagrid

Posted 05 October 2012 - 09:08 AM

```Private Sub Command1_Click()
Dim total1
For i = 0 To DataGrid1.ApproxCount - 1
DataGrid1.Col = 0
total1 = Val(total1) + Val(DataGrid1.Text)
Next
txtTotal.Text = total1
End Sub

```

It only displays the "value of first row* the number of record"
for example:
the first row is 3 and number of record is 15 it will display "15".
I need you help please. Thanks!

correction number of record is 5. Sorry.

Is This A Good Question/Topic? 0

## Replies To: Calculate the total of first column in datagrid

### #2 maj3091

• D.I.C Lover

Reputation: 324
• Posts: 1,925
• Joined: 26-March 09

## Re: Calculate the total of first column in datagrid

Posted 05 October 2012 - 09:38 AM

I'm not that clued up in the datagrid, but I would suspect that you need to increment the row, if you want to sum up the column data, otherwise you'll always stay in the first row.