Solved

How do I multiply columns value in VSFlexgrid ?

Posted on 2008-10-26
5
382 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 46
VBA color chart bars 12 76
bit defender blocks good applications 2 80
Spell Check in VB6 13 95
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now