|
-
Aug 13th, 2002, 09:59 PM
#1
Thread Starter
Junior Member
truncating???
example..
148.87
i just want to get 148 without .87
is there such a function?
without rounding it of course..
thankx!!!!
=====
To follow the path:
look to the master,
follow the master,
walk with the master,
see through the master,
become the master.
-
Aug 13th, 2002, 10:00 PM
#2
So Unbanned
Int() returns the integer portion of a number.
Int(148.87) = 148
-
Aug 13th, 2002, 10:00 PM
#3
The picture isn't missing
msgbox fix(148.87) 'positives
msgbox fix(-148.87) 'and negatives too
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 13th, 2002, 10:01 PM
#4
Frenzied Member
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>
-
Aug 13th, 2002, 10:03 PM
#5
The picture isn't missing
Originally posted by DiGiTaIErRoR
Int() returns the integer portion of a number.
Int(148.87) = 148
if you have anegative number, Int will minus 1 to the number:
MsgBox Int(-147.83) 'returns -148
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 13th, 2002, 10:03 PM
#6
So Unbanned
He didn't mention negative numbers.
-
Aug 13th, 2002, 10:05 PM
#7
Thread Starter
Junior Member
-
Aug 13th, 2002, 11:39 PM
#8
Addicted Member
Try this:
msgbox number \ 1
it'll return an int.
-
Aug 14th, 2002, 11:29 AM
#9
Member
Truncate
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|