LagAbuse.com

Unofficial Section => Programming => Topic started by: OtNePx on January 25, 2014, 08:22

Title: Need help visual basic 6.0
Post by: OtNePx on January 25, 2014, 08:22
Hello,

I am trying to make calculator with visual basic 6.0 for own purposes.

I already made it but i need round numbers after comma (.)

Example:

11.41 / 100 * 1.1394 = 0.13000554

I need only 2 digits after comma it should look 0.13

Any ideas how to make it?
Title: Re: Need help visual basic 6.0
Post by: bassonja on March 21, 2014, 13:34
Don't know in visual basic, but thing you are looking for is rounding numbers, lets say the result is:

0.148349, it will round it to 0.15

There is command for that.
Title: Re: Need help visual basic 6.0
Post by: iErnesto94 on April 04, 2014, 18:16
You want : 0.1365454 to become 0,13 or 0,14

In any ase I can help you
Title: Re: Need help visual basic 6.0
Post by: Grief-Code on July 28, 2014, 09:28
http://msdn.microsoft.com/de-de/library/system.math.round.aspx
Title: Re: Need help visual basic 6.0
Post by: Grief-Code on July 28, 2014, 09:35
However, this link was the first hit when searching for visual+basic+6+round
As you can see, you can round a number now simple on 2 decimal numbers by using
Code: [Select]
/* foo = number to round, bar = decimal numbers */
foo = round( foo, bar);

Advanced:
Code: [Select]
/* small trick to round always up */
foo = round( foo, (bar+1));

/* same goes to always round down */
foo = round( foo, (bar-1));

Regards,
G-C

Ps: Wtf, why I can't edit my own post and this approval sucks.
If you fear spamming on the forum, you can simply go with an anti-spam-bot, for smf there a lot out on the web. I'm not a human.
Title: Re: Need help visual basic 6.0
Post by: Grief-Code on July 28, 2014, 11:08
Small fix:

Code: [Select]
/* small trick to round always up */
foo = round( foo, (bar+0.5));

/* same goes to always round down */
foo = round( foo, (bar-0.5));

Regards,
G-C