Number Formats

  • Thread starter Thread starter Vayse
  • Start date Start date
V

Vayse

I want to display numbers with a comma between every 3 digits, with no
decimal places.
I've tried
Const conFORMAT As String = "###,###,###"

Me.CashTextBox.Text = Format(drEconomy("Cash"), conFORMAT)

Which displays fine in general. For example: 999,817 will come out fine

However, if the value is zero, then the text box will be empty. Is there a
different format I can use to get 0 to displayed correclty?

Thanks

Vayse
 
Not really sure how you want a zero to be formatted, but

(0).ToString("000,000,000") '//Produces 000,000,000
 
Hi Vayse,

This is by design, if a digit is 0, the # will automatically ignore it and
display nothing. Please try to use a pre-defined format string like

Me.TextBox1.Text = Format(0, "N")

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
OHM ( One Handed Man ) said:
Not really sure how you want a zero to be formatted, but

(0).ToString("000,000,000") '//Produces 000,000,000

I don't want zero formatted. If its zero, I just want 0 displayed.
 
Kevin Yu said:
Hi Vayse,

This is by design, if a digit is 0, the # will automatically ignore it and
display nothing. Please try to use a pre-defined format string like

Me.TextBox1.Text = Format(0, "N")

Thanks, but I don't think there is a pre-defined format that matches. "N"
will still display decimal places, which I don't want to do.
I know I can check in code if the number is zero, then use a different
format, but I'm hoping there is a format that would suit.
Vayse
 
Thanks for Patrice's suggestion, N0 will do the trick.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top