Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I multiply columns value in VSFlexgrid ?

Posted on 2008-10-26
5
Medium Priority
?
418 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

722 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