Help: Compute per category-VBForums
Results 1 to 2 of 2

Thread: Help: Compute per category

  1. #1

    Thread Starter
    Registered User
    Join Date
    May 2017

    Help: Compute per category

    Name:  calculate.jpg
Views: 57
Size:  34.8 KB

    I need help how to compute per product and display on the summary (Figure C)

    Figure A - Product Category (loaded via Form_Load)
    - using Listview1

    Figure B - Transaction Summary
    - using Listview3

    Figure C - Transacation Summary per Product Category
    - using Listview2

    If I press the calculate i computes all the amount in the Listview3.

    How will i compute for every category and it must reflect to Figure C?

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    NC, USA

    Re: Help: Compute per category

    I did this using an MSFlexGrid as an example for you. Your code could be similar:
    Private Sub Command1_Click()    Dim x As Integer
        Dim dTopSum As Double
        Dim lTopSum As Double
        With Grid2
            For x = 1 To .Rows - 1
                .Row = x
                If .TextMatrix(x, 1) = "Desktop" Then
                    dTopSum = dTopSum + Val(.TextMatrix(x, 2))
                End If
                If .TextMatrix(x, 1) = "Laptop" Then
                    lTopSum = lTopSum + Val(.TextMatrix(x, 2))
                End If
            Next x
        End With
        Grid3.TextMatrix(1, 1) = CStr(dTopSum)
        Grid3.TextMatrix(2, 1) = CStr(lTopSum)
    End Sub
    NOTE: I removed the commas from the monetary 'values' display so val() would would correctly..other ways of doing it, though!

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