Board index » delphi » OnCalcFields & substring

OnCalcFields & substring

Hi,

i have a picklist in one column of my Grid, and i'd like to do
a diferent calculation depending on selection of these picklist items...
example:

item(tax)  price   all items that dont have the substring "(##%)" tax,  
-----      -----   the operation will be price * 8% (default) but those
diesel      100    with(10%) will be price*10%, so i need to search for
diesel(10%) 150    a substring, i know onCalcfields is called very often
gas          89    and i have a lot of records and picklist with (tax) to
oil         122    search for and calculate, so which the fastest way
other(10%)  342    to do my Calcs in Oncalcfields event?
other       221
 .
 .

and can i do a Sum of colums "tax" and "Totalprice" if they're
calculatedfields?

TIA
Manuel

 

Re:OnCalcFields & substring


Well, you can use the Pos() function. It's a little slow, but it will do.

You can sum calculated columns, but frequently, it's faster to redo the
calculation in the logic that does the sum. Often you can do it more
efficiently. If you do do that, make sure you set AutoCalc to false so
you're not doing it twice!

--
Steve F (Team B)

Quote
"M Jacquez" <mja...@hotmail.com> wrote in message

news:395866C8.6765B27D@hotmail.com...
Quote
> Hi,

> i have a picklist in one column of my Grid, and i'd like to do
> a diferent calculation depending on selection of these picklist items...
> example:

> item(tax)  price   all items that dont have the substring "(##%)" tax,
> -----      -----   the operation will be price * 8% (default) but those
> diesel      100    with(10%) will be price*10%, so i need to search for
> diesel(10%) 150    a substring, i know onCalcfields is called very often
> gas          89    and i have a lot of records and picklist with (tax) to
> oil         122    search for and calculate, so which the fastest way
> other(10%)  342    to do my Calcs in Oncalcfields event?
> other       221
>  .
>  .

> and can i do a Sum of colums "tax" and "Totalprice" if they're
> calculatedfields?

> TIA
> Manuel

Other Threads