Whole Numbers And Rounding Up Or Down?
I've managed to get VB to create and calculate an 'offer' which will be calculated 4 or 5 times throughout the program. The 'offer' nearly always has a decimal place which i dont need, i just want a whole number returned and preferably rounded up or down to the nearest 100.
I've tried:
VB Code: offer = CStr(Left$(offer, 2)) & "00"
but this only works with (say) 3,500 but not 35,000  on the larger numbers it reduces them to 4 figures! but the random offer could be anywhere from 3 figures to 6 figures!
This...
VB Code: offer = Round(offer  2)
seems to work a bit better but will not give 'to the nearest 100' results.
any idea how to get the best of both worlds!?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Rounding Numbers To 2 Decimal Places  How To ? (Rounding)
I am returning math to a variable (and/or a text box) BUT I only want to have two or three decimal places, that are rounded off.
I cant figure out how to round them. I've tried setting text box properties, calling 'as currency' but I dont know what else to do.
Thank you.
Rounding Numbers
Is there a function in VB6 for rounding off numbers? F.instance, I want the number 3,73854689 to be rounded off to 2 decimals, like this: 3,74. Anyone?
Rounding Numbers Down
Hi, I'm having a bit of a problem it goes like this:
1 box = 180 eggs
of course a dozen is 12 and then I have left over individual eggs
I need to take say 16.5 dozen and break it down so that I have three variables, the number of boxes, the number of left over dozens and the number of left over eggs
in this case:
Boxes = 1
Dozens = 1
Eggs = 6
I have tried this:
Code:
Dim JBoxes As Integer
Dim JDozens As Integer
Dim JEggs As Integer
TE = totdozJ * 12 'TE (total eggs) is multiplied by totdozJ (total doz)
JBoxes = TE / 180 'get the no of boxes
R = TE Mod 180 'R remainder of eggs after boxes removed
JDozens = R / 12 'get the number of dozen from the remainder
'problem is here I think
'if R = 18 then divided by 12 gives 1.5 but as this is dimmed as an
'integer because I dont want fractions it rounds up to 2 which
'is plain wrong
R = R Mod 12 'get the number of eggs left
JEggs = R 'assign to correct variable
Any help appreciated  is there a better type of variable, different way to do the operation ??????
Thanks
Rob
Rounding Numbers Down
I have another what is likely a simple question but... lol
Ok I have made a very simple calculator for an online game I play. In the calculator I want to find out how many of a particular item I can buy based on the amount of available cash I have. I need the numbers to be even numbers so I have used the round function with 0 decimal places. However, I want the number to round down REGARDLESS of the decimal. is this possible?
Code:
txtBweapon.Text = Round((weaponcash / 650), 0)
That is one line I have which shows the rounding function.
Any help greatly appreciated
btw VB6 Pro
Rounding Numbers??
Hi, I'm not the greatest coder, butI was just wondering if anyone knew how to round numbers down. So when I click a button it does a calculation like 1,000,000 / 430,000 = 2.3255813953488372093023255813953. I want it so that the answer comes up as just 2 without all the decimal points.
Any help would be great, thanks.
Rounding Numbers
From MSDN:
Quote:
When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.
I noticed that the Round function does the same thing.
Is this the way most of you are to used to round numbers? (I can't imagine it is.) Here in Belgium 0.5 is rounded up to 1. All fractions from 0.5 and more are rounded up.
Is there a standard VB function that rounds numbers in this way?
Rounding Up Numbers
I have made a calculator for a game, but I want all the answers to be rounded up to the nearest whole number. How do I do this? Thanks.
Rounding Numbers
Could someone tell me how to round a number two decimal places like (.00). Here is what I have so far.
Code:
Dialog1.FLosstxt = Int(Val(NutGrid.TextMatrix(b, 6) * (Val(NutGrid.TextMatrix_
(a, 5))  Val(NutGrid.TextMatrix(b, 5))) * 0.01))
Rounding Numbers Down
I have a little problem, and here's what it is.
I have a random number being generated, and it's called "Stat". There's a textbox that text is Stat. I want another textbox's text to be Stat / 2  5 if Stat is even, and if Stat is odd, then I want Stat / 2  5.5 . However, I haven't gotten that working.
I want this other textbox's text to be Stat / 2  5, and if the result would be something like x.5 then I want it to just equal x.
Rounding Up Numbers
Hi! How do I round up a number from double variable and display it in a decimal form? For example: Value of a double is: 90,045672353685847  E5. How do I round it up and display it in this form: 0,0009005 ?
Rounding Numbers
What is a good way to round a number down to the nearest thousand and to round up to the nearest thousand. (NOT DECIMALS, ie. 8654 = 8000 or 8654 = 9000). I have an app that creates Excel charts and depending on the user input, i want the chart to set the x axis(min) to a number rounded down to the nearest thousand and the xaxis(max) to round up to the nearest thousand.
Rounding Whole Numbers
Can anyone tell me how to round whole numbers up to the nearset hundred? Any info that you can give me would be appreciated very much. Thank you.
J.J.
Rounding Numbers
Could anyone help me with rounding a number to the nearest 5, like 5,10,15.......
Thanks for any help
Rounding Numbers
I know how to make an integer from a number... like if i have 1.4 Int(X) = 1
if i have 2.8 Int(X) = 3 etc...
But i want to return an integer that is not rounded, only preserves the number before the dot like
1.4 would give me 1
2.8 would give me 2
Rounding Numbers In VB
I about to punch my computer...ok count to 10.... much better now Here is my problem.
How do I round numbers such as 9.0999999999999 to just 9.09 or whatever it is. I don't have the slighest idea.
Rounding Numbers
Is there a way to limit rounding numbers to just 2 places right of the decimal point?
Rounding Off Numbers
Hi, guys, Im creating program that includes number...
but i find it difficult when it comes to money.. can you give me a sample code that will convert the result into a money(like $125.75) if the answer is 125.7657 it will automatically round off it into $125.77?
Rounding Whole Numbers
I'm trying to create a 'Digits of a Number application' (For Programming Class) that accepts a twodigit number and displays the digits separately. I managed to get the first digit by itself, but I'm struggling will the second digit. My problem is that I cant figure out how to round down integers. Please Help ME!
Code:
'Declare Statesments
Dim intnumber As Integer
Dim intfirst As Integer
Dim intsecond As Integer
'users input
intnumber = lblnumber.Text
'first digit
intfirst = (intnumber  5) / 10
lblfirst.Text = intfirst
'second digit
intsecond = intnumber  Math.Floor(intnumber)
lblsecond.Text = intsecond
Edit* I need help rounding whole numbers down to the tenth place (example: round 93 to 90) so i can get the second digit by itself by subtracting the rounded down number by the input (ex: two digit input: 43 <round this down to the nearest tenth place: 40; then subtract 40 by 43 in order to display the second digit separately from the first: "3"). But the code Math.Floor (highlighted in the yellow) won't round the number, it leaves 'intnumber' as is, which would result my second digit answer: 0 after the following code is executed.
Rounding Numbers
This seems simple, but I can't think of a way to do it... I need to do two things:
Round down to the nearest whole number... (ie, 1.33333 and 1.788835 both become 1)
Round up to the nearest whole number... (ie, 1.33333 and 1.788835 both become 2)
I can't find a good way to do this...
Rounding Numbers
how do you round a number with d.p.s into an integer?
eg 5.7 gets rounded to 6 rather than just getting truncated to 5
Rounding Numbers
Which function do I have to use to round a number to it´s nearest value.
For ex. :
3188.60 to 3190
3147.26 to 3150
3110.15 to 3110
I mean :
I have to round to nearest all value with 5 places.
Thanks...
Rounding Numbers
Code:
Private Sub Command1_Click()
Dim principal As Currency
Dim interest As Double
Dim principal1 As Long
Dim principal2 As Long
Dim principal3 As Long
Dim total As Currency
Dim year As Double
principal = Text1
interest = Text2
year = Text3
total = (((interest / 100) + 1) ^ year * principal)
Label3.Caption = "Amount of money in bank after " & year & " year(s) = £" & total
End Sub
what would you add to this code to get your final answer "total" to round of to two numbers?
Thanks,
Greg
Rounding Numbers
I am trying to multiply the value of 2 text boxes and put it in a lable. I need to round to the 1/100 or .01. I have tried several things, but once again I am stuck.
Code:
Private Sub Command1_Click()
Label1.Caption = Text1.text * Text2.text
End Sub
Rounding Numbers In VB
are you rounding or just truncating?
your example of 100.956 should round to 100.96 not 100.95
serge's code rounds which is not what your example shows
ROUNDING NUMBERS
I need to know how if i had the number 6.5 or 6.6 or 1.6 or 1.7 remove the tens digit without rasing or lowering the ones digit.
Rounding Numbers Up
I am just trying to round a number up to the higher integer. I use VB6 and it will not accept Ceil or ceiling, unless I am doing something wrong. I would have thought it would be a pretty simple command like round () or something, but I can't get anything to work. please help!!
Dim txt1 As Integer
Dim lbl10 As Integer
txt1 = Text1.Text
lbl10 = txt1 / 8
All I need to do is have it round the number up.
Edited by  kbronsman on 7/18/2003 1:16:54 PM
Rounding Off The Numbers In VB
Hi
the ROUND function in VB rounds the number to the nearest decimal, i.e , it rounds 9.6 to 10 and 9.4 to 9.
But I want the number to be always rounded off to previous number. For ex: 9.4 should be rounded to 9 and also 9.9 should also be rounded off to 9.
Is it possible in VB ? Does VB provide any function to do this ?
Thanking in advance
Rounding Numbers
Hi everyone,
I am using a text box to enter a number of days. Then multiplying this by 0.348 and reading this answer into a variable in another text box. I get the proper answer but it goes to 3 decimal places. I am trying to round this number to 2 decimal places.
I have tried Round(text1,2), also
Round(text1.text,2).
I declared the variable as an integer. Do I have to convert the number of days in textbox1 to an integer before trying to round the answer? I get an error that says the Round Function is expecting an = during design time.
This seems a simple thing to do but I can't figure it out yet and am spending too much time on it! My boss is breathing down my neck! HAHA
Any help would be appreciated.
Sandy
Rounding Decimals To Whole Numbers
I am trying to display numerous calculations in a results groupbox but many of the calculations are in decimals I would like to round to the next whole number and display the results in whole number
please help
thanks
brady
Rounding Decimal Numbers
Hi ,
How can I get the Following output
Let's say
input  1.0
output  1
input  1.1
output  2
input 1.2
output 2
'
'
'
input  1.9
output  2
input  2.0
output  2
input  2.1
output  3
input 2.2
output 3
'
'
and so on...
I tried using the round () function , but it gives the output 1 if the input is 1.1, 1.2, 1.3, 1.4
and only gives the output as 2 if the input is 1.5 ,1.6, 1.7 and so on...
please suggest ...
thanks.
Stop Rounding My Numbers!!
OK, here's the problem. I have an Integer, let's say it is 250, and I want it to subtract a decimal amount (like, say, 0.342355). However, if I try this, it will store it as 249 instead of whatever 250 minus 0.342355 is. How do I stop this from happening?? Should I use another type for the big integer? What type should I use?
Rounding Numbers **RESOLVED**
Howdy, folks. I'm programming Access through the form view and the actual code view. I've calculated a value, and now I want to display the value as a 'range'. By that I mean: if the value is 700, I want it to show + or  100, so 600800. That I can do.
My problem is this: I want the number to always be a "nice" number. 1283 is not a "nice" number...1300 is. Then it would show 12001400. How can I make the value round to the nearest "nice" number before displaying it?
 bungee41
Edited by  bungee41 on 3/11/2004 2:35:43 PM
Rounding Up Long Numbers
Hi,
Is it possible to round up to the nearest whole number a long number in v.b.? example...
x = 23.2234
so i want x to be 24
please help if you can.....
Rounding Numbers Off To 2 Decimal Points?
heres the code ive got currently:
Code:
Label12.Caption = ColumnSummary(2) & " bookings (" & (Val(ColumnSummary(2)) / (Val(ColumnSummary(2)) + Val(ColumnSummary(3)))) * 100 & "%)"
Label13.Caption = ColumnSummary(3) & " bookings (" & (Val(ColumnSummary(3)) / (Val(ColumnSummary(2)) + Val(ColumnSummary(3)))) * 100 & "%)"
where columnsumary is adding up the values of a certain column in my flexgrid (here columns 2 and 3)
sometimes i get some painful numbers with huge decimal places, how do i round the value to 2points? thanks everyone
Format Function Is Rounding Numbers ??
Hey!
Is there a way to format a number wirh a floating point without rounding it ?
I thought using the format function (format(myNum, "#0.000"))
will do the job, but for numbers with 4 digits after the floating point, is rounded....
How Can I Prevent Access From Rounding Up / Down Numbers ?
I have a spreadsheet that I would like to convert or rewrite all together into access.
On building my tables and testing them, access takes the value of 'lets say' 2.6 and returns 3. The tables datatype is set to 'number' when this happens. It also returns values I don't want when changing it to 'currency' or 'percentage'.Is there anyway around this....
Note: the result of 2.1 plus 2.5 must return 4.6 not 5.
Thanks... any help will shave off some time in the way we are currently handling the data. (Merging multiple spreadsheets is a drag).
Testkitt2
Rounding Numbers And Eliminating Decimals **RESOLVED**
I'm using VBA in Access to code a form. I'm making a ton of calculations and I want the final number to be an integer or a decimal, when my calculations use decimals. How do I get rid of the decimal?
Also, I want to make numbers rounded off to the nearest multiple of 10. How do I do that?
 bungee41
Edited by  bungee41 on 3/11/2004 2:33:46 PM
ROUNDING NUMBERS Using &"CEIL&" Command
Hey I'm making an AIRMAIL project, and the second a number rolls over from 1.0 to say 1.1 it needs to round up to 2 or the next whole number. ANY SUGGESTIONS on how to round up??
[SOLVED]FormatCurrency Returns Numbers As Text Instead Of Formatted Numbers
This seems as a really dumb question but..... why is it that numbers resulting from a calculation work perfectly BEFORE I format them as currency and DO NOT work as numbers after I have formatted them?
Code:frmDCashFlow.Text7.Text = Val(frmDCashFlow.Text4.Text) + Val(frmDCashFlow.Text5.Text) + Val(frmDCashFlow.Text6.Text) 'This returns a value... OK
frmDCashFlow.Text7.Text = FormatCurrency(frmDCashFlow.Text7.Text, 0) ' This returns numbers as text, that can't be used to calculate once formatted....
Why and how can I avoid this? The FormatCurrency function is supposed to return a numeric expression formatted as currency value.....
Thanks for any help
_________________________________________________________________
Edited by  vbprog1144 on 10/26/2004 1:00:34 PM
Converting String Numbers Into Real Numbers
Hi,
I have a formula in VBA that searches through a table for corresponding results to the conditions I specified and sort the results into another table. My problem is that the data I use, which includes monetary values, seems to have converted them into string numbers (which include de $ sign as part of the characters and not only into a simple visual effect). It's a problem when I want to do mathematic operations with those monetary values. Is there a way to convert them into real numbers in my VBA code just before doing my maths with them? I tried to preformat the cells before their extraction but it seems it isnt enough to really convert them.
Thx!
Werner
Splitting Large Numbers Into Smaller Numbers
i want to divide a decimal into smaller decimals in an array form.
e.g.
starting with 0.22335566
array(0) = 0.22
array(1) = 0.0033 or 3.3 *102
array(2) = 0.000055 or 5.5*104
etc.
can anyone help?
thanx a million
