MSHFlexGrid: Get Total for Rows and Columns


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: MSHFlexGrid: Get Total for Rows and Columns

Hybrid View

  1. #1
    Victor Guest

    MSHFlexGrid: Get Total for Rows and Columns


    Dear VB Pros and Friends:

    Questions about MSHFlexGrid:

    adoRSAnalysis as ADODB.Recordset and it has 5 fields, each is assigned to
    mshflexgrid from column 1 to 5.


    Column 1 is the ItemName, Columns 2 to 5 are the numbers (US $ currency),
    and Column 6 is the total for columns 2 to 5.

    Question 1: how to polulate the adoRSAnalysis¡¯s result into the mshflexgrid?

    Question 2: How to get the row total and show it on column 6?

    Question 3: how to get the total for columns 2 to 5 on the last row (let¡¯s
    say, there are 20 records).

    Question 4: how to format ALL numbers in US currency like Format(.Text, ¡°$#,###,###.00¡±)


    They results should look like this:

    ItemName Column1 ... Column5 Total
    ItemName1 $56.50 $220.52
    ItemName2
    ...
    ...
    ItemName20
    Total $678.90 $2,555.83

    Column 6 and the last row with ¡°Total¡± are the run-time results.


    Thanks



  2. #2
    mgaft Guest

    Re: MSHFlexGrid: Get Total for Rows and Columns


    "Victor" <victoryan88@yahoo.com> wrote:
    >
    >Dear VB Pros and Friends:
    >
    >Questions about MSHFlexGrid:
    >
    >adoRSAnalysis as ADODB.Recordset and it has 5 fields, each is assigned to
    >mshflexgrid from column 1 to 5.
    >
    >
    >Column 1 is the ItemName, Columns 2 to 5 are the numbers (US $ currency),
    >and Column 6 is the total for columns 2 to 5.
    >
    >Question 1: how to polulate the adoRSAnalysis¡¯s result into the mshflexgrid?
    >
    >Question 2: How to get the row total and show it on column 6?
    >
    >Question 3: how to get the total for columns 2 to 5 on the last row (let¡¯s
    >say, there are 20 records).
    >
    >Question 4: how to format ALL numbers in US currency like Format(.Text,

    ¡°$#,###,###.00¡±)
    >
    >
    >They results should look like this:
    >
    >ItemName Column1 ... Column5 Total
    >ItemName1 $56.50 $220.52
    >ItemName2
    >...
    >...
    >ItemName20
    >Total $678.90 $2,555.83
    >
    >Column 6 and the last row with ¡°Total¡± are the run-time results.
    >
    >
    >Thanks
    >
    >


    Assume that MSFlexGrid Name is g
    Dim iRow as Integer, S as Double,s2, as double,s5 as double
    with g
    r.Rows = adoRSAnalysis.RecordCount
    while not adoRSAnalysis.eof
    .textMatrix(iRow,0) = adoRSAnalysis.Fields(0)
    .textMatrix(iRow,1) = Format(adoRSAnalysis.Fields(1),"$#,###,###.00")
    .textMatrix(iRow,2) = format(adoRSAnalysis.Fields(2),"$#,###,###.00")
    .textMatrix(iRow,3) = format(adoRSAnalysis.Fields(3),"$#,###,###.00")
    . textMatrix(iRow,4) = format(adoRSAnalysis.Fields(4),"$#,###,###.00")
    s = adoRsAnalysis.Fields(1)+adoRSAnalysis.Fields(2)+ _
    adoRSAnalysis.Fields(3)+adoRSAnalysis.Fields(4)
    . textMatrix(iRow,5) = format(s,"$#,###,###.00")
    s2 = s2 +adoRsAnalysis.Fields(1)
    s5 = s5 +adoRsAnalysis.Fields(4)

    .textMatrix
    adoRSAnalysis.MoveNext
    wend
    adoRSAnalysis.Close
    end with
    lblTotal2.caption = format(s2,"$#,###,###.00")
    lblTotal5.caption = format(s5,"$#,###,###.00")





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center