Solved

Formatting numbers

Posted on 2014-01-09
1
163 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 69

Accepted Solution

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now