Solved

Formatting numbers

Posted on 2014-01-09
1
166 Views
Last Modified: 2014-01-09
I know that I can format a number to a given set of decimal places but is there anyway to format a number so that it only writes decimal places as needed?  

     For example, if I perform a set of calculations that result in variables (type: decimal) equaling the numbers 9, 123.0034, 5.7 and 0.02.  Is there a format that I can use to give me these exact results?  I do not want 9.0000, 5.7000 and 0.0200 but 123.0034 is fine.
0
Comment
Question by:NevSoFly
1 Comment
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 39768219
have you tried: younumbervar.ToString("#,##0.####")
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question