example..
148.87
i just want to get 148 without .87
is there such a function?:rolleyes:
without rounding it of course..
thankx!!!!
Printable View
example..
148.87
i just want to get 148 without .87
is there such a function?:rolleyes:
without rounding it of course..
thankx!!!!
Int() returns the integer portion of a number.
Int(148.87) = 148
msgbox fix(148.87) 'positives
msgbox fix(-148.87) 'and negatives too
Dim strThis As String, intDec As Integer
strThis = "148.87"
intDec = InStr(1, strThis, ".")
MsgBox Left(strThis, intDec - 1)
<edit>guess it depends on where you're coming from</edit>
if you have anegative number, Int will minus 1 to the number:Quote:
Originally posted by DiGiTaIErRoR
Int() returns the integer portion of a number.
Int(148.87) = 148
MsgBox Int(-147.83) 'returns -148
He didn't mention negative numbers.
thankx everyone...
really nice forum!!!:D :D :D :D :D :D :D :D :D :D
Try this:
msgbox number \ 1
it'll return an int.
This truncates a value to a number of decimal places and returns the value.
Public Function Truncate(Value As Double, Places As Integer) As double
Dim tp As String
Dim P As Integer
tp = Format$(Value, "0." & String$(Places + 3, "0"))
P = InStr(1, tp, ".")
Truncate = cdbl(Left$(tp, P + Places))
End Function