473,408 Members | 1,821 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,408 software developers and data experts.

Decimal format display

126 100+
Hullo Friends,
I need your help. Please help me.

I am using C#NEt2008 to develop Window Application to calculate Monthly Repayment amount
of the LOAN amount of 12 months of payment

It's working but the txtPayment.text is not displaying the required data

instead of 833.33 txtPayment.text display 833.33333333

Expand|Select|Wrap|Line Numbers
  1. private double intLoan ;
  2. private int intMthCount;
  3.  
  4. private void btnCalculate_Click(object sender,EventArgs e)
  5. {    
  6. intLoan = Convert.Todouble(this.txtLoan.text); // 10,000
  7. intPayMth = (int) (this.txtRepaymentMth.text);    // 12                 
  8. this.txtPayment.text =(decimal)(this.intTotalLoan / intYearMth);
  9. }
  10.  
  11.  
Sep 22 '10 #1
2 1988
Use the format specifiers. Please look at the links below.

string formated = string.format("{0:0.00} to {1:0.00}", decOne, decTwo);

Custom Numeric Format Strings
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

Standard Numeric Format Strings
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
Sep 22 '10 #2
lenniekuah
126 100+
Hi ZiadElmalki,
Thank you very much for your sample coding and URL Address. Finally I got it working and learned something new.

Here are the working codes:
Expand|Select|Wrap|Line Numbers
  1. this.txtPayment.text = String.Format("{0:0,0.##}", (this.intTotalLoan / intYearMth));  
Sep 22 '10 #3

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

Similar topics

0
by: Tobias | last post by:
Hi all, is it possible to set decimal-format in any way by using a variable or similar? Example: <xsl:variable name="myseparator" select="@separator"/> <xsl:decimal-format...
1
by: | last post by:
Hi all, Is there one operation to do the following more efficiently,need to format upto 500 in one go decimal d; d.ToString("N2").PadLeft(12); thank you.
2
by: Rahul | last post by:
Hey Guys I have a development environment, in which the whole SQL syntax is stored in the Database. So the syntax in the databse column could be "where BirthDate = '12/31/2005' and ID =...
1
by: John | last post by:
Hi, I have varaiables declared as float, the result of .ToString() is like 1.0000. How can I get rid of the 0s in the decimal? e.g. 1.0000 will be 1 and 1.3500 will be 1.35 TIA
3
by: kimi | last post by:
hi all, can anyone tell me how to convert a comp-1 floating point number to a decimal in REXX??
0
by: kreed | last post by:
I am trying to write a script that returns a decimal value where the value in the column is only two characters. The values in the column I am returning are currenlty 4 character AND 2 characters. ...
3
by: mpl | last post by:
i want to write a decimal value to a xml attribute. my code is element.setattribute(amount,myamount.decimalvalue.tostring); my amount value is 10. this displayes as 10. instead when my...
1
by: veer | last post by:
hello expert i made a programe in vb6.0 and i want to display the price in decimal format like e.g. 2323.90 i am sending my program line where i want to change the price format ls1Level =...
1
by: karanbikash | last post by:
Hi , I have a requirement where in I need to display the decimal value of 0.00 as '######.00' SELECT case when DECIMAL(AMT_CHEQUE,31,2) = 0.00 THEN 9999999999999.9999999 ELSE ...
7
by: Andrus | last post by:
How to create format string for decimal data type which shows blank for zero and default format otherwize ? I tried format string "f;f;#" but this shows f for nonzero numbers. Andrus. ...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.