1,105,391 Community Members

Two Decimal Places

Member Avatar
ptaylor965
Junior Poster
169 posts since Oct 2006
Reputation Points: 6 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
Could you please show me how to get
1.9
to show with two decimal places (1.90)


you can use

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

Member Avatar
QVeen72
Veteran Poster
1,016 posts since Nov 2006
Reputation Points: 104 [?]
Q&As Helped to Solve: 164 [?]
Skill Endorsements: 7 [?]
 
0
 

Hi,

Check this :

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

Regards
Veena

Question Answered as of 6 Years Ago by QVeen72
Member Avatar
ptaylor965
Junior Poster
169 posts since Oct 2006
Reputation Points: 6 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
eGadgetGuy
Newbie Poster
1 post since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
Could you please show me how to get
1.9
to show with two decimal places (1.90)


you can use

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...

CStr(dblResult.ToString("#,##0.00"))

It worked for me and it does round up/down as needed.

Member Avatar
ssommaro
Newbie Poster
2 posts since Jan 2010
Reputation Points: 1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
2
 

If you store your number in a variable of decimal type, you can convert into a string with two decimal places (including .00) this way:

Dim dAmount as Decimal
Dim strFormattedAmount as String

strFormattedAmount= dAmount.ToString("N2")


Hi,
Could you please show me how to get
1.9
to show with two decimal places (1.90)


you can use

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

Member Avatar
vbdotnettut
Newbie Poster
3 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

If you store your number in a variable of decimal type, you can convert into a string with two decimal places (including .00) this way:

Dim dAmount as Decimal
Dim strFormattedAmount as String

strFormattedAmount= dAmount.ToString("N2")

Try this:
String.Format("{0:f2}", CType("10.22222222", Decimal))
http://vbdotnettutorial.blogspot.com/2010/05/vbnet-format-to-2-decimal-points.html

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

Please do not resurrect old threads. If you want to ask question, start your own thread. Please read the rules before posting again - http://www.daniweb.com/forums/thread78223.html and rules.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article