Solved

How do I multiply columns value in VSFlexgrid ?

Posted on 2008-10-26
5
404 Views
Last Modified: 2013-12-26
Hi,
I'm using VSFlexgrid on my forms and I am using VB6 language. I want to multiply column 1 with column 2 and the result will be placed in third column like we do in price multiply by qty to get total amount and also I want to get all rows total in a text box outside the grid.
 thanks
0
Comment
Question by:khalidsuhail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:FER_G
ID: 22812217
khalidsuhail; To get the result of multiply col1 * col2, you can do...
while you are populating the grid... you must get the total of the multiply operation of each row...
With VSFlexgrid1
   .TextMatrix(ActualRow, 1) = 2 'qty
   .TextMatrix(ActualRow, 2) = 1.25 'price
   .TextMatrix(ActualRow, 3) = val(.TextMatrix(.row, 1)) * val(.TextMatrix(.row, 2))
end with
...do this for each row that you add to the grid

then, you can obtain the total result of col3 with the Aggregate Property, like this...
With VSFlexgrid1
   txtTotal.text = .Aggregate(flexSTSum, .fixedRows, 3, .rows-1, 3)
end with

I hope the helps you.
Regards.
FerG.
Saludos
--
Ing. Fernando D. Giletta
San Fco. Cba. Argentina.
0
 

Author Comment

by:khalidsuhail
ID: 22816155
Thanks for your reply. But I dont want any constant values. What do you mean by ActualRow and 1
how would I know which row and which column my user in?
and where am I going to place these code? in what event VSFlesgrid???
 
0
 
LVL 7

Accepted Solution

by:
FER_G earned 500 total points
ID: 22816221
ah, SO you want to calculate the multiply after the user input the values in the grid.
So, you must do that, in the NEXT EVENT.

Private Sub VSFlexgrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
    With VSFlexGrid1
        .TextMatrix(Row, 3) = Val(.TextMatrix(Row, 1)) * Val(.TextMatrix(Row, 2))
    End With
End Sub

Regards.
FerG.
Saludos
--
Ing. Fernando D. Giletta
San Fco. Cba. Argentina.
0
 

Author Comment

by:khalidsuhail
ID: 22818912
Is there any online documentation or help available for VSFlexgrid.
0
 
LVL 7

Expert Comment

by:FER_G
ID: 22820080
yes!, there is.
The help file is "vsflex8.chm". I don´t know if there's any online documentation, so, you've to google it....
but, could solve your problem with the code snippet?

FerG.
Saludos
--
Ing. Fernando D. Giletta
San Fco. Cba. Argentina.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question