Solved

How do I multiply columns value in VSFlexgrid ?

Posted on 2008-10-26
5
379 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Is there any online documentation or help available for VSFlexgrid.
0
 
LVL 7

Expert Comment

by:FER_G
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

763 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

9 Experts available now in Live!

Get 1:1 Help Now