top of page

86. Remove "and No Cents"

Description

Suppress "and No Cents" when dollar amounts do not have a cent value.

Code

"«Amount-n:Nine Dollars and Twelve Cents»"
IF LAST( RESULT, 13 ) CONTAINS "and no cents"
FIRST( RESULT, LENGTH( RESULT ) - 13 )
END IF

Explanation

This computation formats a number variable, Amount-n, in the form "Nine Dollars and Twelve Cents." If, however, there is no cent value, the computation will trim off the string " and No Cents," returning only the dollar amount. For example:

$5.06 - Five Dollars and Six Cents
$5.00 - Five Dollars

To accomplish this, the computation is first set to the value of the number variable nAmount formatted as "Nine Dollars and Twelve Cents." We then look at this string (it is stored in RESULT) to see if its last 13 characters are " and no cents." If so, we trim off that part of the string. To do this, we take only the FIRST x characters of the string, where x is the length of the string - 13.

©2023 by My Site. Proudly created with Wix.com

  • Facebook
  • Twitter
  • LinkedIn
bottom of page