|
-
Dec 4th, 2001, 05:45 PM
#1
Thread Starter
Junior Member
Ceiling and Floor Function?
Hi there,
can ya tell me whether there is ceiling and/or floor function in VB?
thx
Regards
ES
-
Dec 4th, 2001, 05:49 PM
#2
Frenzied Member
What do u mean ceiling and floor? Do u mean the Max and Min in some data?
You just proved that sig advertisements work.
-
Dec 4th, 2001, 05:50 PM
#3
-= B u g S l a y e r =-
damn u lost me there speedsolo... what do u mean ?
-
Dec 4th, 2001, 05:50 PM
#4
Member
There's a floor, just cast it to a type that doesn't support decimals:
VB Code:
Const xWithDecimals As Double = 3.14159
Dim xWithoutDecimals As Long
xWithoutDecimals = CLng(xWithDecimals)
Msgbox "Before: " & xWithDecimals & vbCrLf & "After: " & xWithoutDecimals
-
Dec 4th, 2001, 05:51 PM
#5
Member
Originally posted by peet
damn u lost me there speedsolo... what do u mean ?
Floor rounds a number down, Ceiling rounds a number up.
-
Dec 4th, 2001, 05:55 PM
#6
Frenzied Member
Well heres a ceiling function then...
VB Code:
Function Ceiling(n As Double) As Long
If Not Int(n) = n Then
Ceiling = Int(n) + 1
Else
Ceiling = n
End If
End Function
You just proved that sig advertisements work.
-
Dec 4th, 2001, 05:58 PM
#7
Thread Starter
Junior Member
eg
Ceiling(1.5) = 2
Floor(1.5) = 1
and thanks filburt1 for your suggestion, I will try it out later
-
Dec 4th, 2001, 06:07 PM
#8
Thread Starter
Junior Member
Just tried filburt1's code but there's some problem. Found in MSDN:
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.
then I moved to nishantp's and it seems fine.
anyway, thanks v.much, you guys
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
|