DaWolf has asked for the wisdom of the Perl Monks concerning the following question:
So, it works pretty fine:sub FormatValue { $c = 0; $vl = $_[0]; if ($vl ne "0,00" and $vl ne "0" and $vl ne ",00" and $vl ne ".0000") { if ($vl =~ m/(\.0000)/) { $vl =~ s/(\.0000)$/,00/; } else { $vl .= ",00"; } ($interessa,$zeros) = split (",",$vl); $compr = length $interessa; $c = int ($compr / 3); if ($c eq 1 and $compr > 3) { $um = substr($interessa, -3, 3); $interessa =~ s/$um/\.$um/; } elsif ($c eq 2) { $um = substr($interessa, -6, 3); $dois = substr($interessa, -3, 3); $interessa =~ s/$um/$um\./; } $result = $interessa.",".$zeros; } else { $result = "0,00"; } return $result; }
| Value of Access | Returned by sub |
| 36000.0000 | 36.000,00 |
| 12725.0000 | 12.725,00 |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formatting MS Access Currency Values
by Molt (Chaplain) on Apr 23, 2002 at 15:00 UTC | |
|
Re: Formatting MS Access Currency Values
by graff (Chancellor) on Apr 23, 2002 at 15:31 UTC | |
|
Re: Formatting MS Access Currency Values
by graff (Chancellor) on Apr 23, 2002 at 15:50 UTC | |
|
Re: Formatting MS Access Currency Values
by gryphon (Abbot) on Apr 23, 2002 at 15:39 UTC |