Difference between revisions of "Formatting Numbers"
(Created page with 'The best way to format numbers for output is to use the Format() function. It seems to work fine on either a string that looks like a number or just a regular number. Here is a …') |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The best way to format numbers for output is to use the Format() function. It seems to work fine on either a string that looks like a number or just a regular number. | + | The best way to format numbers for output is to use the Format() function. Unlike the Str() function, Format does not add an extra space in front of positive numbers. It seems to work fine on either a string that looks like a number or just a regular number. # represents a number, 0 can also be a number or a required leading or trailing zero. |
Here is a simple use of Format() to show two decimal places: | Here is a simple use of Format() to show two decimal places: | ||
Line 6: | Line 6: | ||
strText = "EL. " & Format(elev, "###0.00") | strText = "EL. " & Format(elev, "###0.00") | ||
EL. 1040.25 | EL. 1040.25 | ||
+ | EL. 4.25 | ||
+ | EL. 0.80 | ||
</PRE> | </PRE> | ||
Line 11: | Line 13: | ||
<PRE> | <PRE> | ||
− | strText = "STA. " & Format(sta, "# | + | strText = "STA. " & Format(sta, "#0+00.00") |
STA. 35+52.00 | STA. 35+52.00 | ||
+ | STA. 0+08.15 | ||
</PRE> | </PRE> |
Latest revision as of 17:28, 16 August 2010
The best way to format numbers for output is to use the Format() function. Unlike the Str() function, Format does not add an extra space in front of positive numbers. It seems to work fine on either a string that looks like a number or just a regular number. # represents a number, 0 can also be a number or a required leading or trailing zero.
Here is a simple use of Format() to show two decimal places:
strText = "EL. " & Format(elev, "###0.00") EL. 1040.25 EL. 4.25 EL. 0.80
Stationing in surveying puts a separator after the hundreds marker so you can generate the proper format with this statement:
strText = "STA. " & Format(sta, "#0+00.00") STA. 35+52.00 STA. 0+08.15