Two Decimal Places

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Two Decimal Places

 
0
  #1
Jul 28th, 2007
Hi,
Could you please show me how to get
1.9
to show with two decimal places (1.90)


you can use
  1. Math.Round(1.99999999, 2)
if you want to bring the decimal places down to two
but how do you increase from zero or one decimal place up to two?


Thanks
Peter
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Two Decimal Places

 
0
  #2
Jul 29th, 2007
Hi,

Check this :

TextBox1.Text = Format(1.9, "0.00")
 
TextBox2.Text = Format(22, "0.00")

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Two Decimal Places

 
0
  #3
Jul 29th, 2007
Thanks QVeen72,
It work perfectly.

I've only ever used Format with Dates beform and it never occured to used it with numerics


Thanks
Peter
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: eGadgetGuy is an unknown quantity at this point 
Solved Threads: 0
eGadgetGuy eGadgetGuy is offline Offline
Newbie Poster

Re: Two Decimal Places

 
0
  #4
May 10th, 2009
Originally Posted by ptaylor965 View Post
Hi,
Could you please show me how to get
1.9
to show with two decimal places (1.90)


you can use
  1. Math.Round(1.99999999, 2)
if you want to bring the decimal places down to two
but how do you increase from zero or one decimal place up to two?


Thanks
Peter
You can also use; assuming the variable is named dblResult...
  1. CStr(dblResult.ToString("#,##0.00"))
It worked for me and it does round up/down as needed.
Last edited by eGadgetGuy; May 10th, 2009 at 7:53 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 33599 | Replies: 3
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC