[off-topic] Visual Basic Question - rounding up?

Thanks Mark and Wayne, I had been searching for a command like 'roundup' in
excel. With your help, it's working now!



[Non-text portions of this message have been removed]
I am setting a field value based on equation. The resulting files needs to
be an integer. The caluculation may result ina fraction. I want the
calculated number to always round up to the next integer value to set the
field. (ex. 4.2 = 5, 4.6 = 5, 4.0 = 4). If anyone know how to do this, I
would GREATLy appreciate it!!!
Use the truncate command to compare the truncated value to the actual.
For example:

IF FIX(ActualVal) <> ActualVal then
ActualVal = FIX(Actualval + 1).


That should round up all decimal values to the next largest number for
all positive numbers. If you are dealing with negative numbers you might
have to use the INT() function to get the desired result.

Mark Charamut
President
Caesar Development Services, LLC
mcharamut@...
www.caesardev.com
(860) 667-4774 x20




-----Original Message-----
From: sarah.vareschi@... [mailto:sarah.vareschi@...]
Sent: Thursday, April 04, 2002 2:22 PM
To: vantage@yahoogroups.com
Subject: [Vantage] [off-topic] Visual Basic Question - rounding up?


I am setting a field value based on equation. The resulting files needs
to
be an integer. The caluculation may result ina fraction. I want the
calculated number to always round up to the next integer value to set
the
field. (ex. 4.2 = 5, 4.6 = 5, 4.0 = 4). If anyone know how to do this,
I
would GREATLy appreciate it!!!


Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder
and Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links

Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Many languages have a function called Ceiling to do exactly what you
describe. VB lacks such a function. Here's the code for a home-grown
version.

Public Function Ceiling(sngNumberIn As Single) As Integer
Dim intInputToInteger

intInputToInteger = Int(sngNumberIn)

If sngNumberIn = intInputToInteger Then
Ceiling = intInputToInteger
Else
Ceiling = intInputToInteger + 1
End If

End Function

Hope this helps ...

Larry Kurtze
Aspacia Systems Inc
27 North Wacker Drive, Suite 422
Chicago IL 60606
866.566.9600, Fax 312.803.0730
www.aspacia.com
lkurtze@...


-----Original Message-----
From: sarah.vareschi@... [mailto:sarah.vareschi@...]

Sent: Thursday, April 04, 2002 1:22 PM
To: vantage@yahoogroups.com
Subject: [Vantage] [off-topic] Visual Basic Question - rounding up?

I am setting a field value based on equation. The resulting files needs
to
be an integer. The caluculation may result ina fraction. I want the
calculated number to always round up to the next integer value to set
the
field. (ex. 4.2 = 5, 4.6 = 5, 4.0 = 4). If anyone know how to do this,
I
would GREATLy appreciate it!!!
As far as I know there isn't a specific function to do exactly what you
want, but the following will work:

If Int(YourNum) = (YourNum) Then
Int(YourNum)
Else
Int(YourNum) + 1
End If

Int takes the integer portion of the number and ignores the rest. The
integer portion of 4.0 is 4. If this equals 4.0 (and it does) then you want
4 as your value. If your number is 4.3, the integer portion is 4, but 4
doesn't equal 4.3 so you take the integer portion, which is 4, and add 1 to
round it to the next whole number.

Hope this helps,

Christopher Gitzlaff
Manager - Information Systems & Technology
Major Industries, Inc.
Phone: 715-842-4616
Fax: 715-848-3336


-----Original Message-----
From: sarah.vareschi@... [mailto:sarah.vareschi@...]
Sent: Thursday, April 04, 2002 1:22 PM
To: vantage@yahoogroups.com
Subject: [Vantage] [off-topic] Visual Basic Question - rounding up?


I am setting a field value based on equation. The resulting files needs to
be an integer. The caluculation may result ina fraction. I want the
calculated number to always round up to the next integer value to set the
field. (ex. 4.2 = 5, 4.6 = 5, 4.0 = 4). If anyone know how to do this, I
would GREATLy appreciate it!!!


Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and
Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
At 02:21 PM 4/4/2002 -0500, you wrote:
>be an integer. The caluculation may result ina fraction. I want the
>calculated number to always round up to the next integer value to set the
>field. (ex. 4.2 = 5, 4.6 = 5, 4.0 = 4). If anyone know how to do this, I

I usually use something like: X = Int( X + 0.99 )

[you might have to correct the function name for the Int() thing - I
haven't used VB in years, but most everything calls it that]

-Wayne