When I use
String.Format("{0:#,###}", intNumber)
it works fine until intNumber = 0, and then it returns an empty string!
I just want to show all numbers with commas in thousands place. Is there a
better way? I tried "0,0", but that returns "00" when the integer is 0. 4 2840
D. Patrick wrote: When I use String.Format("{0:#,###}", intNumber) it works fine until intNumber = 0, and then it returns an empty string!
I just want to show all numbers with commas in thousands place. Is there a better way? I tried "0,0", but that returns "00" when the integer is 0.
You're close "#,0" worked for me. So did "#,##0" and as far as I can
tell they are the same.
BTW does anyone out there have a good list of all the different format
strings? I wasn't able to find much on MSDN. Info seems a bit scarce
in this area. Below are a few links I found: http://blogs.msdn.com/kathykam/archi...29/564426.aspx http://blog.stevex.net/index.php/str...ing-in-csharp/
--
David Hogue
it do not support your format about ","
example
int intNumber=0 ;
if(intNumber ==0)
{
MessageBox.Show("0");
}
else
{
MessageBox.Show(String.Format("{0:#,###}", intNumber));
}
cheers
"D. Patrick" wrote: When I use String.Format("{0:#,###}", intNumber) it works fine until intNumber = 0, and then it returns an empty string!
I just want to show all numbers with commas in thousands place. Is there a better way? I tried "0,0", but that returns "00" when the integer is 0.
I appreciate the post, but do you mean this is really by design? And people
must always test for 0 separately? That seems like a mistake.
"jongwoo" <jo*****@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com... it do not support your format about ","
example
int intNumber=0 ; if(intNumber ==0) { MessageBox.Show("0"); } else { MessageBox.Show(String.Format("{0:#,###}", intNumber)); }
cheers
"D. Patrick" wrote:
When I use String.Format("{0:#,###}", intNumber) it works fine until intNumber = 0, and then it returns an empty string!
I just want to show all numbers with commas in thousands place. Is there a better way? I tried "0,0", but that returns "00" when the integer is 0.
"D. Patrick" <re*****************@thenotreal.com>'s wild
thoughts were released on Wed, 14 Jun 2006 03:41:36 GMT
bearing the following fruit: When I use String.Format("{0:#,###}", intNumber) it works fine until intNumber = 0, and then it returns an empty string!
That is the correct and documented behaviour.
I just want to show all numbers with commas in thousands place. Is there a better way? I tried "0,0", but that returns "00" when the integer is 0.
You can specifically tell it what you want it to do when the
value is 0
String.Format("{0:#,###;;zero}", intNumber)
or simply
String.Format("{0:#,##0",intNumber)
Jan Hyde (VB MVP)
--
Incest is relatively boring. Necrophillia is dead boring. (Hugh Janus) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Willem-Jan Selen |
last post by:
Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far...
|
by: Eagle |
last post by:
This seems to be a pretty basic question, but I can't find the answer. In
VB I format a number by:
format("1234", "#.00") (result: 1234.00)
This doesn't work in asp, I get an error. How do I...
|
by: Simon Brooke |
last post by:
I'm investigating a bug a customer has reported in our database
abstraction layer, and it's making me very unhappy.
Brief summary:
I have a database abstraction layer which is intended to...
|
by: Tom Petersen |
last post by:
I must have the format of the below line wrong for IE:
click <a href="cal.asp?sdate=<% =strDate1 %>&location=<% =strLocation
%>&eTime=<% =strDate2 %>">here</a> to add this information to your...
|
by: stevek |
last post by:
How do I format an integer. Add commas.
1234565 1,234,565
TIA
|
by: mark |
last post by:
How do I get all fields on one page of a report?
I have a report that has a column for each day of the week and 6 records for
each day. I need each weekday's records returned on only one detail...
|
by: Danny Lesandrini |
last post by:
I'm using an Access database to drive a web site and the
colors of various table backgrounds are stored in Access.
I want users of the Access database to be able to select
colors for the site, but...
|
by: Michael Howes |
last post by:
MSDN documentation for format strings seems ambiguous. It's says
things like "significant digits or number of decimal places" all over
the place. Well those two things are different.
How do I...
|
by: Dixie |
last post by:
I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |