Wrox Programmer Forums
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2007, 12:55 PM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Truncate 10/3

Help me with C# code(Windows Programming)
I have 3 textboxes and a button
two textbox accept number while third textbox displays the divsion on button click event
suppose 10/3 = 3.333333333
I want truncate it to 3.333 only i.e., (three digits after decimal)
Help me



 
Old March 20th, 2007, 08:58 PM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to CloudRose
Default

format the result by using ".ToString(System.IFormatProvider provide)".

 
Old March 20th, 2007, 09:26 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

consider

float fNum = (Convert.ToInt32(textBox1.Text) / Convert.ToInt32(textBox2.Text));
label1.Text = String.Format("{0:n}", fNum);

If fNum contained the value 3.3333333333 label1.Text will contain the value 3.33

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 21st, 2007, 01:17 AM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thankyou for your help!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystalreport 10 nilesh kureriha BOOK: Professional Crystal Reports for VS.NET 0 May 30th, 2007 01:28 AM
Crystal Reports Truncate Numbers from ASP flankovich Classic ASP Professional 0 May 30th, 2006 10:14 AM
Chapter 10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 March 29th, 2005 09:35 AM
Chapter 10 columbiasmiles JSP Basics 0 May 17th, 2004 08:09 PM
HELP > bulk insert - need to truncate field nlicata SQL Language 1 February 26th, 2004 10:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.