473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Rounding Up to the nearest 100

Please give me some advice with regards to rounding a numerical figure up to the nearest hundred.
EG: 256 >> 300
654 >> 700
15 >> 100
I would like to know the formula to enter into Visual Basic 2008. I'm making a calculator Program, and i need a function that rounds up to the nearest 100...

Please help
Jul 28 '12 #1
5 22042
Frinavale
9,735 Expert Mod 8TB
Use the Math.Round method.

-Frinny
Jul 28 '12 #2
This is my formula so far:

Label6.Text = Math.Round(Label5.Text / 100, 0) * 100

It rounding to the nearest 10 at the moment (43>>40; 47>>50)
I need it to round up to the nearest 100

So if it's: 43>>100
59>>100
97>>100
101>>200
3980>>4000
You get the point

How do i achieve this?
Jul 29 '12 #3
lyodmichael
75 64KB
hmm, if you want you can use if label5.text < 100 or > 0 .

#tip
Jul 29 '12 #4
how do i write that into the formula?
I'm really really new at this
sorry
Jul 29 '12 #5
Frinavale
9,735 Expert Mod 8TB
Well first you need to divide the value that you are rounding by 100. This will give you a double value which you can round. Once you have that, you can multiply it by 100 to round to the nearest 100.

Expand|Select|Wrap|Line Numbers
  1. private static int RoundValueToNearst100(double value)
  2. {
  3.   int result =(int) Math.Round(value / 100);
  4.   if (value > 0 && result == 0) {
  5.     result = 1;
  6.   }
  7.   return (int) result * 100;
  8. }
-Frinny
Jul 30 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: b | last post by:
Hello all, we have a table that is part of our accounting package that stores decimals as such: 123.45678. However the reporting standards with the accounting system display that as 123.45 note...
8
by: Zorpiedoman | last post by:
Howcome: Dim D as decimal = .5D msgbox d.Round(D, 0) this returns "0" Now when I went to school .5 rounds UP to 1 not DOWN to zero?????!!! Documentation says this, but what the heck are...
6
by: Jeff Boes | last post by:
(asked last week on .questions, no response) Can anyone explain why this happens? (under 7.4.1) select '2004-05-27 09:00:00.500001-04' :: timestamp(0) ; timestamp ---------------------...
12
by: 6tc1 | last post by:
Hi all, I just discovered a rounding error that occurs in C#. I'm sure this is an old issue, but it is new to me and resulted in a fair amount of time trying to track down the issue. Basically...
11
by: cj | last post by:
Lets assume all calculations are done with decimal data types so things are as precise as possible. When it comes to the final rounding to cut a check to pay dividends for example in VB rounding...
29
by: Marco | last post by:
Hello, I have : float f = 36.09999999; When I do : char cf; sprintf(cf,"%0.03lf", f); I get : 36.100
5
by: Spoon | last post by:
Hello everyone, I don't understand how the lrint() function works. long lrint(double x); The function returns the nearest long integer to x, consistent with the current rounding mode. It...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
20
by: jacob navia | last post by:
Hi "How can I round a number to x decimal places" ? This question keeps appearing. I would propose the following solution #include <float.h> #include <math.h>
30
by: bdsatish | last post by:
The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.