?
Solved

How to format decimal figures limiting the # of decimals, place commas or not.  Same for currency.

Posted on 2005-03-25
6
Medium Priority
?
18,350 Views
Last Modified: 2011-08-18
I am loading a datagrid with a decimal field and have chosen a "C" format in my column mapping.  The source field is decimal, scale of 0.  The display gives me $ sign, commas and two decimals.  I went to a format "D" and the same result minus the $ sign.  I think there should be a rather easy way to control the basic numeric display formatting but beyond using "C" or "D" I can't seem to find the answer.  Also, will the answer work for a text box as well?
0
Comment
Question by:JayNichols
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
Lacutah earned 500 total points
ID: 13633391
# = Optional Number
0 (zero) = Required Number

To format a decimal with up to 5 but always at least 3 decimal places:
#.000##

with that format 3.141596 will be displayed as "3.14159" and 0.6 would be displayed as ".600"
0
 
LVL 9

Expert Comment

by:Lacutah
ID: 13633395
I'm going to double-check that answer - I've been using Access 97 formatting too much lately..
0
 

Author Comment

by:JayNichols
ID: 13633597
I'm going to have to have a VB.NET answer.  Thanks anyway.  I think it is in the column formatting but can't seem to find anything that will do the job.  Possibly just blind. :-)  

However the results of your answer is exactly what I am looking for.  Say, for the 3.141596, being able to view it as 3 or 3.14, etc.  Same for currency.  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:amyhxu
ID: 13634097
if you use customed dataGrid Column Style, when adding the decimal column, simply add: TextBoxCol.Format = "##,##0.00"

Otherwise,
Dim dgtb As DataGridTextBoxColumn = dataGrid1.TableStyles(0).GridColumnStyles("YourDecimalColumnName")
dgtb.Format = "##,##0.00"
0
 
LVL 9

Expert Comment

by:Lacutah
ID: 13634128
For Currency, use:
$#,##0.00

The formatting is same (still), this is legacy stuff...  I was refering to using Access' formatting lots, and rarely having to use it in .NET, but the format codes (in this case) are the same which is where I was concerned.
0
 

Author Comment

by:JayNichols
ID: 13652417
Thank you, one and all.  Lacutah, I gave you the points but amyhxu was exceedingly helpful as well.  Is there anyway in this system one can split the points?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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