VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Rounding Posted by MartyWebb on 17 Sept 2004 at 6:24 PM
I need to know if it's possible to round off a numerical value that's a decimal to a specified number of decimals, ie. tenths, hundredths, thousandths and so-on? Can anyone help?
Report
Re: Rounding Posted by kainsworth on 18 Sept 2004 at 1:14 AM
This message was edited by kainsworth at 2004-9-18 1:16:49

: I need to know if it's possible to round off a numerical value that's a decimal to a specified number of decimals, ie. tenths, hundredths, thousandths and so-on? Can anyone help?
:



It certainly is You can use the built-in Round function.
  Dim d As Double = 34.7764645454
  Label1.Text = Math.Round(d, 3)

The first argument is the number you want to truncate, the second one is the level of precision - in the above example it will truncate to three decimal places)

Hope this helps

Ged



Report
Re: Rounding Posted by MartyWebb on 18 Sept 2004 at 4:17 AM
: This message was edited by kainsworth at 2004-9-18 1:16:49

: : I need to know if it's possible to round off a numerical value that's a decimal to a specified number of decimals, ie. tenths, hundredths, thousandths and so-on? Can anyone help?
: :
:
:
:
: It certainly is You can use the built-in Round function.
:
:   Dim d As Double = 34.7764645454
:   Label1.Text = Math.Round(d, 3)
: 

: The first argument is the number you want to truncate, the second one is the level of precision - in the above example it will truncate to three decimal places)
:
: Hope this helps
:
: Ged
:
:
:
:
Oh it most certainly did, I just got done putting it in, I know it was probably a simple thing, I'm just a beginner, I come from a world of 20+ years of programming in COBOL RPG and Fortran plus various 4GL languages, so I kind of new there had to be a way to do it, just not sure how, unfortunately the book we have doesn't even MENTION Math.Round... anyway, thanks very much for your help
Report
Re: Rounding Posted by kainsworth on 18 Sept 2004 at 4:50 AM
: : This message was edited by kainsworth at 2004-9-18 1:16:49

: : : I need to know if it's possible to round off a numerical value that's a decimal to a specified number of decimals, ie. tenths, hundredths, thousandths and so-on? Can anyone help?
: : :
: :
: :
: :
: : It certainly is You can use the built-in Round function.
: :
: :   Dim d As Double = 34.7764645454
: :   Label1.Text = Math.Round(d, 3)
: : 

: : The first argument is the number you want to truncate, the second one is the level of precision - in the above example it will truncate to three decimal places)
: :
: : Hope this helps
: :
: : Ged
: :
: :
: :
: :
: Oh it most certainly did, I just got done putting it in, I know it was probably a simple thing, I'm just a beginner, I come from a world of 20+ years of programming in COBOL RPG and Fortran plus various 4GL languages, so I kind of new there had to be a way to do it, just not sure how, unfortunately the book we have doesn't even MENTION Math.Round... anyway, thanks very much for your help
:

Pleased that it did The "problem" - if problem it is - with .Net is that there are just so many classes, functions, methods, etc built into it that it's just impossible to cram them all into a single book. Still it's nice to be spoilt for choice!

The nearest to achieving this that I know of is Francesco Balena with his 1600(!) page book "Programming Visual Basic.Net", MS Press. But even he has had to leave a lot of detail out, so you get an idea of just how much stuff there is tucked away inside that Framework.






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.