Reversing Sign
I want to reverse the sign on some numbers, printing them as a negative
instead of a positive. So, I put the following code in an OnGetText event.
Text:=CurrToStr(-StrToCurr(Text));
It compiles fine, but when I go to run the report, it tells me: "Could not
run program: DBText20OnGetText" which is referring to the component where I
have inserted this code above. I also have tried rewriting the code to use
a variable and do three steps to get the same result. The error message is
the same. Can anyone explain why I get this error message when the RAP code
compiles with no errors?
The variable is a currency variable, but the OnGetText defines the Text as a
string, so I am assuming that I must convert Text to currency and back
again. I tried doing Text:='-'+Text, but this shows a negative before
numbers that are 0.00, which is not desirable.
David Miller.
instead of a positive. So, I put the following code in an OnGetText event.
Text:=CurrToStr(-StrToCurr(Text));
It compiles fine, but when I go to run the report, it tells me: "Could not
run program: DBText20OnGetText" which is referring to the component where I
have inserted this code above. I also have tried rewriting the code to use
a variable and do three steps to get the same result. The error message is
the same. Can anyone explain why I get this error message when the RAP code
compiles with no errors?
The variable is a currency variable, but the OnGetText defines the Text as a
string, so I am assuming that I must convert Text to currency and back
again. I tried doing Text:='-'+Text, but this shows a negative before
numbers that are 0.00, which is not desirable.
David Miller.
This discussion has been closed.
Comments
The following RAP code worked for me. The StrToCurr is simply a pass thru
function to the Delphi StrToCurr method.
lTemp := StrToCurr('-' + Text);
Text := CurrToStr(lTemp);
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
code:
var
c1 : currency;
begin
c1:=StrToCurr('-'+Text);
Text:=CurrToStr(c1);
end;
It still gives me the same error message. Again, the code compiles with no
errors, but when the report is previewed on the screen, I get "Could not run
program: DBText20OnGetText"
David Miller
currency symbol ($), which was causing the StrToCurr function to raise an
exception. Thanks for your help.
David Miller