Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to add leading zeros based on length

Status
Not open for further replies.
Jan 20, 2003
41
US
I am trying to write a formula to add leading zero's to
a number that will have varying lengths. The pic clause
I am trying to create is 9999.99, the original length varies. Is there an easy way to do this? Any help would be appreciated as I am new at this.
 
The decimal point causes a small hitch, otherwise it's very simple so I'll make the assumption that you do not have anything with a value less than 1.

Create a formula something like:

if len(totext(2345.67,2,&quot;&quot;)) < 8 then
replicatestring(&quot;0&quot;,8-(len(totext(2345.67,2,&quot;&quot;))))+totext(2345.67,2,&quot;&quot;)

Replacing the 2345.67 with your field.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top