Manage Learn to apply best practices and optimize your operations.

# Code To Convert A Number Value To A Text String. Useful In Check Printing Or Report Writing Apps.

I don't know how the formula will look on the web page, since there is a lot
there :) But it should come out correctly when you cut and paste it!

PURPOSE: This code will convert a number value to a text string. The current
limitation is that the number can be no longer than five digits, and only whole
numbers are accounted for.

TO USE: Paste this code in a "Computed" field and replace "Amount" (in the
first line) to the value you want to convert it will take the number and make
it into a string.

APPLICATION: I used this in an application where I integrated IntelliPrint,
and I needed to print checks with the wording spelled out. (ex. \$1230.00 would
be ONE THOUSAND TWO HUNDRED THIRTY DOLLARS)
txtAmount := @Text( @Integer(Amount) );
length := @Length( txtAmount );

fromSingle := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
toSingle := " " : " ONE" : " TWO" : " THREE" : " FOUR" : " FIVE" : " SIX" : "
SEVEN" : " EIGHT" : " NINE";

fromTens := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
toTens := " " : " TEN" : " TWENTY" : " THIRTY" : " FOURTY" : " FIFTY" : "
SIXTY" : " SEVENTY" : " EIGHTY" : " NINETY";

fromDouble := "11" : "12" : "13" : "14" : "15" : "16" : "17" : "18" : "19";
toDouble := " ELEVEN" : " TWELVE" : " THIRTEEN" : " FOURTEEN" : " FIFTEEN" : "
SIXTEEN" : " SEVENTEEN" : " EIGHTEEN" : " NINETEEN";

value :=
@If( length=5;
@Do( @If( @Length( @ReplaceSubstring( @Left( txtAmount; 2 ); fromDouble;
toDouble ) ) > 2;
@ReplaceSubstring( @Left( txtAmount; 2 ); fromDouble;
toDouble ) + " THOUSAND ";
@ReplaceSubstring( @Left( txtAmount; 1 ); fromTens; toTens )
+ @ReplaceSubstring( @Right( @Left( txtAmount; 2 ); 1); fromSingle; toSingle )
+ " THOUSAND " ) ) +
@ReplaceSubstring( @Right( @Left( txtAmount; 3 ); 1);
fromSingle; toSingle ) + @Do( @If( @Right( @Left( txtAmount; 3 ); 1) = "0"; "";
" HUNDRED ") ) +
@Do( @If( @Length( @ReplaceSubstring( @Right(
txtAmount; 2 ); fromDouble; toDouble ) ) > 2;
@ReplaceSubstring( @Right(
txtAmount; 2 ); fromDouble; toDouble );
@ReplaceSubstring( @Left( @Right(
txtAmount; 2 ); 1 ); fromTens; toTens ) + @ReplaceSubstring( @Right( txtAmount;
1); fromSingle; toSingle ) ) );
length=4;
@ReplaceSubstring( @Left( txtAmount; 1 ); fromSingle; toSingle ) + " THOUSAND "
+
@ReplaceSubstring( @Right( @Left( txtAmount; 2 ); 1); fromSingle; toSingle ) +
@Do( @If( @Right( @Left( txtAmount; 2 ); 1) = "0"; ""; " HUNDRED ") ) +
@Do( @If( @Length( @ReplaceSubstring( @Right( txtAmount; 2 );
fromDouble; toDouble ) ) > 2;
@ReplaceSubstring( @Right( txtAmount; 2 );
fromDouble; toDouble );
@ReplaceSubstring( @Left( @Right(
txtAmount; 2 ); 1 ); fromTens; toTens ) + @ReplaceSubstring( @Right( txtAmount;
1); fromSingle; toSingle ) ) );
length=3;
@ReplaceSubstring( @Left( txtAmount; 1 ); fromSingle; toSingle ) + " HUNDRED " +
@Do( @If( @Length( @ReplaceSubstring( @Right( txtAmount; 2 );
fromDouble; toDouble ) ) > 2;
@ReplaceSubstring( @Right( txtAmount; 2 );
fromDouble; toDouble );
@ReplaceSubstring( @Left( @Right(
txtAmount; 2 ); 1 ); fromTens; toTens ) + @ReplaceSubstring( @Right( txtAmount;
1); fromSingle; toSingle ) ) );
length=2;
@Do( @If( @Length( @ReplaceSubstring( @Left( txtAmount; 2 ); fromDouble;
toDouble ) ) > 2;
@ReplaceSubstring( @Left( txtAmount; 2 ); fromDouble;
toDouble );
@ReplaceSubstring( @Left( txtAmount; 1 ); fromTens; toTens )
+ @ReplaceSubstring( @Right( @Left( txtAmount; 2 ); 1); fromSingle; toSingle )
) );
length=1;
@ReplaceSubstring( @Left( txtAmount; 1 ); fromSingle; toSingle );
"");

@Trim(value) + " DOLLARS"

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Updated Exchange Online PowerShell module adds reliability, speed

Microsoft assists Exchange Online administrators who rely on PowerShell by reworking the underlying functionality of several ...

• ### Mammoth March Patch Tuesday lands on Windows admins

Microsoft delivers corrections for 115 unique vulnerabilities, including 26 bugs rated critical in one of its largest Patch ...

• ### Understanding Windows PowerShell function parameters

Parameters in Windows PowerShell can help admins better customize their functions, leading to improved input testing and more ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Tech giants aim supercomputers, clouds at finding a COVID-19 cure

The new COVID-19 HPC consortium comprised of tech giants, national labs and academia are using supercomputers and clouds to speed...

• ### Top vendor SDDC certification programs for admins

If you decide to grow your knowledge of software-defined data center technologies, VMware, Nuage Networks and Microsoft offer ...

• ### Build up your knowledge of leaf-spine network technology

As organizations deal with challenges of single tree path networks, many admins are considering leaf-spine architectures. Learn ...

## SearchContentManagement

• ### Vendors offer free remote work technology for telecommuting

It's more than a marketing ploy: Cloud technology vendors, seeing their own issues enabling remote work, extend paid products to ...

• ### How businesses should deal with enterprise search issues

Enterprise search issues frequently complicate user experience with ECM systems. While users may face many problems, they also ...

• ### Box, Dropbox shore up clouds; Box-Microsoft integrations go live

Online document collaboration platforms Box and Dropbox shore up cloud bandwidth, security and customer support as remote work ...

Close