Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get total of flexgrid column

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
0
0
US
How do I get the total of a flexgrid column. I'm trying to use:

Public Function GetTotal()
Dim Total
i = 0 to flexGrid.Rows - 1
Total = Total + flexGrid.TextMatrix(i, 0)
Next
txtTotal = Total
End Function

The above just concatonates the numbers instead of adding them together. Like:

1
1 =11

Instead of

1
1 = 2

I've tried using CStr, CDbl, CSng, but none of them work either. Rob
Just my $.02.
 
I'm no expert but aren't you missing the FOR statement for your loop?
 
Yep. I copied and pasted that code. I actually do have a For in the code. Don't know why it didn't copy over. I may have deleted it somehow after I pasted it. I've tried adding Hours = 0 before the loop too. Still no go. Thanks. Rob
Just my $.02.
 
I think that it is thinking your working with string so I think if you make total an integer and get the value of the flex grid it should work.

Public Function GetTotal()
Dim Total as integer
Total = 0
for i = 0 to flexGrid.Rows - 1
Total = Total + val(flexGrid.TextMatrix(i, 0))
Next
txtTotal = Total
End Function
Randy
smiletiniest.gif


You can Email me at: RCooper@cinci.rr.com
 
Thanks for the reply Randy. I finally figured out what I was doing wrong. I should have been using:

For i = 2 to FlexGrid.Rows - 1

My information in the FlexGrid doesn't start until the second row.

I tried Val eariler. I don't think it works in VBScript.

Thanks again for taking the time to answer my post.

Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top