Function (numberVar Amount)
numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :="";
stringvar ckAmt:="";
Amt := ABS(Amount);
ckAmt := CSTR(ABS(Amount));
if Amt > 10000000 then
RmVal :=
truncate(Amt/10000000);
if Amt = 10000000 then
RmVal := 1;
if RmVal = 1 then
InWords := InWords
+ "1,"
else if RmVal < 10 and RmVal > 1 then
InWords :=
InWords + ToText(RmVal,0) + ",";
// Amt := Amt -
Rmval * 10000000;
if RmVal >= 10 then
InWords := InWords + ToText(RmVal,0) +
",";
Amt := Amt -
Rmval * 10000000;
if Amt > 100000
then
RmVal :=
truncate(Amt/100000);
if Amt = 100000
then
RmVal := 1;
if Amt < 100000
then
RmVal := 0;
if (RmVal = 1) And
(Len(InWords) = 0) then
InWords :=
InWords + ToText(RmVal,0) +
","
else if RmVal = 1
then
InWords :=
InWords + '0' + ToText(RmVal,0) + ","
else if (RmVal
< 1) and (Len(InWords) > 0) then
InWords :=
InWords + "00,";
if RmVal <
10 and RmVal > 1 and (Len(InWords)
> 0) then
InWords :=
InWords + "0" + ToText(Rmval,0) + ","
else if RmVal
< 10 and RmVal > 1 then
InWords :=
InWords + ToText(Rmval,0) + ",";
if
RmVal >= 10 and RmVal < 100 then
InWords :=
InWords + ToText(RmVal,0) + ",";
Amt := Amt
- Rmval * 100000;
if Amt
> 1000 then
RmVal
:= truncate(Amt/1000);
if Amt
< 1000 then
RmVal := 0;
if Amt =
1000 then
RmVal
:= 1;
if RmVal =
1 and (Len(InWords) > 0) then
InWords := InWords + "0" + ToText(RmVal,0) + ",";
if RmVal =
1 and (Len(InWords) = 0) then
InWords := InWords +
ToText(RmVal,0) + ","
else
if (RmVal < 1) and (Len(InWords) > 0) then
InWords := InWords + "00,";
if
RmVal < 10 and RmVal > 1 and
(Len(InWords) > 0) then
InWords := InWords + "0" + ToText(RmVal,0) + ","
else if RmVal < 10 and RmVal > 1
then
InWords := InWords +
ToText(RmVal,0) + ",";
if
RmVal >= 10 and RmVal < 100 then
InWords := InWords + ToText(RmVal,0) + ",";
Amt := Amt - Rmval * 1000;
if Amt > 99 then
if Amount >= 0 then
InWords :=
InWords + ToText(Amt,0)
else
InWords :=
"-" + InWords + ToText(Amt,0)
else if Amt > 9 and (Len(InWords) > 0) then
if Amt > 9 and Amt < 9.999 and (Len(ckAmt) > 5)
then
InWords :=
InWords + "00" +ToText(Amt,0)
else if Amount >= 0 then
InWords :=
InWords + "0" +ToText(Amt,0)
else
InWords :=
"-" + InWords + "0" +ToText(Amt,0)
else if Amt >= 0 and (Len(InWords) > 0) then
if Amount >= 0 then
InWords :=
InWords + "00" +ToText(Amt,0)
else
InWords :=
"-" + InWords + "00" +ToText(Amt,0)
else if Amt >= 0 then
if Amount >= 0 then
InWords :=
ToText(Amt,0)
else
InWords :=
"-"+ ToText(Amt,0)
No comments:
Post a Comment