Stripping Decimals

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Is there a format function or something to strip decimals
out of a number? In other words, if I have 581.77, I
want my query to read the number as 58177.

Also, if I want to place leading zeros in front of the
new number I just created, how could I do that? I need a
total of 10 numbers, including the new number:

0000058177

Thanks,
Steve
 
Is there a format function or something to strip decimals
out of a number? In other words, if I have 581.77, I
want my query to read the number as 58177.

Multiply by 100.
Also, if I want to place leading zeros in front of the
new number I just created, how could I do that? I need a
total of 10 numbers, including the new number:

0000058177

If this is to be a text string (it's too big to be an integer or a
long!) use the Format() function:

Format(100 * number, "0000000000")
 
Steve,

In addition to John's suggestions, if you don't know how many decimal places
there'll be, you can remove the dot:
myNumber = Replace(CStr(dblMyNum), ".", "")

....and as John suggests, to force a width:
myNumber = Format(Replace(CStr(dblMyNum), ".", ""), "0000000000")

Of course, Replace() is only available in Access 2000 and later.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top