473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Code separator

I have the following code and want my total to include a comma as a thousand separater. how do i go about it
Expand|Select|Wrap|Line Numbers
  1. else if (itemType == 1) // debit
  2.             {
  3.                 total += Convert.ToDecimal(rec.getAmount());
  4.                 //total=Convert.ToDecimal(total);
  5.                 outFile.Write("{0}                          {1}", rec.getAmount().PadRight(13, ' '), total.ToString().PadLeft(13, ' '));
  6.             }
  7.             else
  8.             {
  9.                 total +=Convert.ToDecimal(rec.getAmount());
  10.                 outFile.Write("                     {0}     {1}", rec.getAmount().PadRight(13, ' '), total.ToString().PadLeft(13, ' '));
  11.             }
  12.             if (putTemplate) outFile.Write("|"); else outFile.Write(" ");
  13.             putEndOfLine();
  14.             recnDetailNeeded = disp.needRecn();
  15.  
May 30 '07 #1
2 1216
Hi

Below is the code to convert a double to specific currency format.

Double MyVal = 78692.92786;
string CurrencyFormat = string.Format("{0:##,###,##}", MyVal);
May 30 '07 #2
Plater
7,872 Expert 4TB
The .ToString() on numbers can take a format string. Check MSDN for a list of NumberFormatInfo's. One of them is specifically designed to add a thousands seperator
May 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Pedro Graca | last post by:
<?php function ugly_array() { return array(1, 2, 3, 4, 5); } $arr = ugly_array(); echo $arr; ?> not so ugly :) now ... I want to get rid of the $arr temporary variable.
7
by: Coder Droid | last post by:
After much searching, I can't seem to find any definitive way to determine which path separator to use. Obviously, it's ":" on nix, and ";" on windows ... so what's the best way to determine what...
30
by: Stephen Ferg | last post by:
I have a question that is not directly Python-related. But I thought I'd ask the most erudite group that I know... :-) When did Windows start accepting the forward slash as a path separator...
16
by: Douglas | last post by:
Gday, How would I format a number so that: TheValue = 32500 Displays in the TextBox as: $32,500.00
3
by: Carmen Z. | last post by:
do you know how to write a script so that the number that is coming from database with thousand separator (comma) will be eliminated and shown to a web page? so if the value is 1,200, i wanto...
9
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a...
10
by: T.K Kullervo | last post by:
Hi, is there someway to change the regional settings--> numbers--> decimal separator for the the program im creating. I dont want to change it permanently but my program doesnt work if the...
2
by: ari | last post by:
I have a small form that comprises a toolbar, a treeview and a status bar. Everything was working fine until I decided to add a new button to the toolbar - and I decided for appearances sake to...
8
by: Larry Bates | last post by:
I have a project that I wanted to solicit some advice on from this group. I have millions of pages of scanned documents with each page in and individual .JPG file. When the documents were scanned...
69
by: Jack Dowson | last post by:
Hello Everybody: I'm learning c now.I think it's really a tedious job following my textbook to write programs which are used to deal with math problems.I want to write some codes related with...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.