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!

Formatting a number

Status
Not open for further replies.

demoniac

Programmer
Jun 14, 2001
63
US
Hello, I have a number and I need to format it to the cobol number format... Like this :

before : 59.80
after : 000005980

Getting rid of the decimal is easy, just multiply by a hundred. But I can't make the leading 0's get in there. Can someone help me? :)

Thanks,
demoniac
 
Are you storing your result in a variable? If so you may have to make the variable a string so that it will hold the leading zeros and if necessary, convert it back for calculation purposes.
 


lngNumber = 59.80 * 100

strCobolNum = Format$(lngNumber, "000000000")
 
Try Format(number*100,"000000000") where number contains the figure to be converted. You can print this directly or set a variable, as Format returns a variable of type Variant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top