Specifying decimals

noosaj

Member
Joined
Mar 5, 2007
Messages
6
Programming Experience
Beginner
Hello,

First off, I apologize if I am posting this in the wrong forum - I can't seem to find which one is appropriate.

I am trying to figure out how to specify the number of digits AFTER a decimal period that I want returned. For example, let's say I want to specify that a calculation returns/rounds off up to three decimal places.. or two. How do I go about doing that in VB2005?

Thanks!

Jason
 
Math.Round(doublevalue, 3)
 
Where exactly would I put this in my code? After VB does the calculations, or when it is supposed to output the results to a label?

Thanks!
 
Math.Round function has one simple task; to take the number input you give it and return the number output of the rounding operation. So you have to give it a number and it will give you a new number in return. If you want to display the return value in a Label control you have to first catch the return value, convert it to a string value, then assign that string to the Label controls Text property. All this can be done with a single line of code, example:
VB.NET:
TheLabelControl.Text = Math.Round(12341234.12341234, 3).ToString
 
Back
Top