473,487 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Formatting decimals

C
Hi,

I have an aspx with some labels.

I set the text of these labels to be teh return value of
some Functions that carry out some calculations.
(My Functions return decimals)

I want to format the value I write to my label so that it
is transformed for example from 87123.13 to 87,123.13

This probably quite simple but I am unsure.

Any help or direction to online help much appreciated.

Thanks,
C
Jul 19 '05 #1
1 1579
C <c@nospam.com> wrote:
I have an aspx with some labels.

I set the text of these labels to be teh return value of
some Functions that carry out some calculations.
(My Functions return decimals)

I want to format the value I write to my label so that it
is transformed for example from 87123.13 to 87,123.13

This probably quite simple but I am unsure.


You need the "number" format specifier, "n". For instance:

using System;

class Test
{
static void Main()
{
decimal d = 87123.13m;
Console.WriteLine ("{0:n}", d);
}
}

prints

87,123.13
(in an English culture).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
18644
by: J | last post by:
Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number...
1
1589
by: D. Shane Fowlkes | last post by:
Hey guys. I have a Repeater and a Template. One of the dataitems calls a helper function. The dataitem sends the record ID to the function and the function runs a complex query and returns a...
1
1027
by: thomson | last post by:
Hi all, i do have a Text Box for Amount , Almost all my forms are dealing with Amounts, In My Setup I specify that only 2 decimals are allowed , in all the amounts, How do i set this...
8
1096
by: coleenholley | last post by:
I'm trying to format this bit of code into a numeric format of 12,123 no decimals in the particular format. Here's the code: tbl_worksheet1.Rows(b).Cells(2).Text() = Format(ls_sum_gasohol,...
1
312
by: C | last post by:
Hi, I have an aspx with some labels. I set the text of these labels to be teh return value of some Functions that carry out some calculations. (My Functions return decimals) I want to...
1
2075
by: pebelund | last post by:
Hi I got an .aspx that got the following code (example) <td width="120"> <% = row %> </td> row takes a value from a SQL db, that is a string of numbers. On the webbsite I want this to show...
14
4241
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
9
2305
by: john coltrane | last post by:
Is there way to create a formatted string in a similar that is similar to sprintf? The same for printing, printf? C,D,E,F,G,N,X for currency, decimal, exponential, fixed, general, numerical,...
30
2673
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.