Format function gibes back a string

  • Thread starter Thread starter Jonas
  • Start date Start date
J

Jonas

Hi guys,

does anybody know how can I reach the following effect.
I want to format a floating point number like 45,233 in the way that only
two digits after the comma are show, but they should be there even when the
number in an integer value like 4,00.
So I tried to do it with format(...) but I get back a string.
Type casting the result of format cuts the digits after the comma or rather
distroys the format.

F.e.: 5,6 -> CSng(format(5,67,"#,##0.00")) -> 5,6
but I want to have all my numbers with two digits after the comma as a
number.
Like

4,3 -> 4,30
123 -> 123,00

How can I do that ?

Thanks in advance.

Regards

Jonas
 
Hi Jonas,

The format() function by definition returns a string. There are functions
that return formatted numbers, such as FormatNumber(), FormatCurrency(), and
FormatPercent(); but, I believe that there may be an easier way to do what
you want to do.

If I understand your post correctly, you really just want to format the
number to display to two decimal places. If that is the case, the easiest
way to do this is generally to look at the field properties in a query, or
the control properties in a form or report, and set the decimal places
property to 2.

For more advanced number formats, you can put the entire format picture in
the number format property. In either case, the number will remain a number
and not be converted to a string.

Hopefully that will help, please post back if I misunderstood your post.

-Ted Allen
 
Back
Top