Round Number

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Round Number
GoodGuy17
Hello,
Does anyone know how to round a number Vb gave me to a whole? Example:
3.53566611111
to
3
I need help for my temperature converter BETA in the showroom section.
Please help me so I can rule the world :twisted: lol.
~GoodGuy17 :D
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Round Number
CodenStuff
Hello,

You can use:
Code: Select all
Decimal.Round("3.53566611111")
That should round it to the closest number cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Round Number
GoodGuy17
Can I just put that code in a button after the part where it puts the number in the textbox?
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Round Number
CodenStuff
Hello,

Not sure what you mean GoodGuy17, you just use it like:
Code: Select all
Textbox1.Text = Decimal.Round("1.33")
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Round Number
Nery
Hmm you can't specify the number of characters you want to round?
Lets assume I want to round this number:
1,33333333...
but with 3 characters, it should round to this:
1,333
5 posts Page 1 of 1
Return to “Tutorial Requests”