Results 1 to 5 of 5

Thread: [Resolved]Totaling up columns in an mshflexgrid

  1. #1

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    Resolved [Resolved]Totaling up columns in an mshflexgrid

    Hey all.

    I have an mshflexgrid with some numerical data in it, and Id like to do a command click to count the numbers in each column and total them at the bottom like this

    1 | 2
    3 | 3
    2 | 1
    5 | 2
    -----------
    11 | 8

    How would I do this?
    Last edited by DKasler; Feb 8th, 2006 at 12:11 PM.
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Totaling up columns in an mshflexgrid

    Try something like this
    VB Code:
    1. Dim i as long, j as Long, Total as Double
    2. For j = 1 to MsFlexgrid1.Cols - 1
    3.      Total = 0
    4.      For i = 1 to MsFlexgrid1.Rows - 2 'The Row before Last Row
    5.            Total  = Total  + Val(MsFlexgrid1.TextMatrix(i, j))
    6.      Next
    7.      MsFlexgrid1.TextMatrix(.Rows-1, j) = Total  'Add Col Total to the last Row
    8. Next
    Last edited by jcis; Feb 8th, 2006 at 11:52 AM.

  3. #3

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    Re: Totaling up columns in an mshflexgrid

    Im getting an argument not optional error on

    VB Code:
    1. Total = Total + Val(MSHFlexGrid2.TextMatrix)

    Specifically on the .textmatrix

    I dont know if it matters but im using a MSHFlexGrid and your example uses a MSFlexgrid. I dont know if the Hierarchial thing matters.
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Totaling up columns in an mshflexgrid

    I updated the code in my previous post

  5. #5

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    Re: Totaling up columns in an mshflexgrid

    AWESOME! Thanks SO Much!
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width