Jump to content
  • Advertisement
Sign in to follow this  
phil05

Need help with decimal formatting in VB.NET

This topic is 4914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Images speak a thousand words, so here ya go... I'll need something to format and round in the hundredth place after each decimal. My VB.NET book for college doesn't teach this, so it's leaving me confused. I don't need the problem solved for me, but some help in what methods to use will be helpful. Thanks in advanced, Phil

Share this post


Link to post
Share on other sites
Advertisement
First of all, hallelujah for another VB.NET guy. I don't feel so alone.
For your problem, you can also use the math.round method. Example:

Dim testnum as double
testnum = 1027.270403431
testnum = math.round(testnum,2)

testnum will now be 1027.27
the first number in math.round is the number to be rounded, the second is the number of digits to round it to. I assume you are using Visual Studio. You can use intellisense to find out what functions need. Math.round has four parameter sets you can enter. Hope this helps. Your way is good too. You answered your own question while I was typing this, so I figured I might as well post anyway.

Share this post


Link to post
Share on other sites
Learning more than one solution is always a bonus for later, so thank you for your help!

Phil

Texas_Brigade.AddRate(rate = rate + 1)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!