[RESOLVED] Return only Full Numbers
For example, if I want to divide 27 / 15 it gives me 1.8.
What is the way for me just to return just the complete part of the value returned?
It doesn't matter if the value is 199.9, I still only want the 199.
This is probably quite simple, but I have done very little maths in VB before. :ehh:
Re: Return only Full Numbers
Use the Integer Division Operator (backslash) then:
27 \ 15 = 1
Quote:
\ Operator
Used to divide two numbers and return an integer result.
Syntax
result = number1\number2
The \ operator syntax has these parts:
Part Description
result Required; any numericvariable.
number1 Required; anynumeric expression.
number2 Required; any numeric expression.
Remarks
Before division is performed, the numeric expressions are rounded toByte,Integer, orLong expressions.
Usually, thedata type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Long variant, regardless of whether result is a whole number. Any fractional portion is truncated. However, if anyexpression isNull, result is Null. Any expression that isEmpty is treated as 0.
Re: Return only Full Numbers
Flip the / into a \ and use integer division... that's the easiest... I don't know if it give 1 or if it gives 2 (1.8 rounded).... additionally, look at teh Round, Floor and Ceiling functions.
-tg
Re: Return only Full Numbers
The function equivalent of integer (\) division is Int():
x \ y = Int(x / y)
Note that Int() can handle any number, whereas integer (\) division bombs out for values greater than Long. (Just over 2 billion.) This can come into play if you're using Currency, Single, or Double.
Re: Return only Full Numbers
Re: Return only Full Numbers
Thanks for all the replies everybody :thumb: