473,770 Members | 4,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ROUND up

I have the following equation.

<% varWT = Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) +
CInt(Session("w "))) %>

Assume....
Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) = .12
CInt(Session("w ")) = 30

How can I get it to always ROUND up to 31 ...?

thanks
Oct 31 '05 #1
3 6352
shank wrote on 31 okt 2005 in microsoft.publi c.inetserver.as p.general:
I have the following equation.

<% varWT = Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) +
CInt(Session("w "))) %>

Assume....
Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) = .12
Impossible assumption, since that would be rounded to 0
CInt(Session("w ")) = 30

How can I get it to always ROUND up to 31 ...?


a = .12
b = 30
c = a + b '30.12

if int(c)<c then c = int(c) + 1

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 31 '05 #2

"shank" <sh***@tampabay .rr.com> wrote in message
news:us******** ******@TK2MSFTN GP10.phx.gbl...
I have the following equation.

<% varWT = Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) +
CInt(Session("w "))) %>

Assume....
Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) = .12
CInt(Session("w ")) = 30

How can I get it to always ROUND up to 31 ...?

thanks


How 'bout ...

Test to see if CInt(rsFreePack .Fields.Item("W eight").Value) <
CDbl(rsFreePack .Fields.Item("W eight").Value) and, if so, add 1 to
CInt(rsFreePack .Fields.Item("W eight").Value) otherwise just use
CInt(rsFreePack .Fields.Item("W eight").Value).

CInt() truncates the fractional part as does CLng().
Oct 31 '05 #3
Here's a RoundUp function I have written that hopefully might help:

Function jpsvbRoundUp(pv arNum, pvarDecimals)
' Purpose: Round up.
' Remarks: Usually makes numbers farther from 0 even if the important
digit is less than 5.
' Examples:
' jpsvbRoundUp(3. 451, 2) -> 3.46
' jpsvbRoundUp(-3.451, 2) -> -3.46

' Dim var.
Dim varNum
Dim varDecimals
Dim varBigValue

' Quick exit if either item not numeric.
If (Not IsNumeric(pvarN um)) Or (Not IsNumeric(pvarD ecimals)) Then
jpsvbRoundUp = 0
Exit Function
End If

' Set var.
varNum = pvarNum

' Round decimals to an integer in case not one already.
' (Note that VBScript's Round() also rounds its decimals parameter.)
' (If used CInt() instead of Round() it could have had a rounding error
' if important digit were 5.)
varDecimals = Round(pvarDecim als, 0)

' Convert 3.456 to 2 decimal places up to be 345.6
varBigValue = varNum * 10 ^ varDecimals

If varBigValue = Fix(varBigValue ) Then
jpsvbRoundUp = varBigValue / 10 ^ varDecimals
Else
' Add 1 to the above 345.6 to get 346.6.
' (But if the orig number is neg., then subtract 1 instead.)
' Then chop off the fractional .6 to leave 346.
' Then convert 346 back down to 3.46.
If varNum >= 0 Then
jpsvbRoundUp = Fix(varBigValue + 1) / 10 ^ varDecimals
Else
jpsvbRoundUp = Fix(varBigValue - 1) / 10 ^ varDecimals
End If
End If
End Function

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

<<
I have the following equation.

<% varWT = Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) +
CInt(Session("w "))) %>

Assume....
Round(CInt((rsF reePack.Fields. Item("Weight"). Value)) = .12
CInt(Session("w ")) = 30

How can I get it to always ROUND up to 31 ...?

thanks


*** Sent via Developersdex http://www.developersdex.com ***
Nov 2 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3131
by: Matias Silva | last post by:
Can anybody tell me why I am getting rounding errors using the ROUND function. 3.7125 rounds to 3.70 when I use the following: TRUNCATE(ROUND(units_pay_amount * fees_amount, 2),2))) The correct value should be 3.71 I could round to the 3rd decimal place ROUND(X,3) and that would round it correctly to 3.71 but that would mean I would have to change the ROUND function in another
6
18672
by: Penguin | last post by:
At some long ago time Steve Jorgensen answered thus: Subject: Re: How can I round a time? Newsgroups: comp.databases.ms-access Date: 1998/12/11 Access represents a date internally as a double and will convert between date/time and double automatically. The double value Access (or VB) creates is based on 1 day = 1.0 and the fractional part represents a
17
5659
by: nomenklatura | last post by:
Hi, System.Math.Round function is confused me. for example i want to round 3.245 in with decimal symbol Result should be = 3.25 When i try to this in vb: A = 3.245 X = Round(A, 2) then x=3.24 , result is is false
9
7385
by: Ronald W. Roberts | last post by:
I'm having a problem understanding the Round function. Below are quotes from two books on VB.NET. The first book shows examples with one argument and how it rounds. The second book something different. Programming Microsoft Windows with Microsoft Visual Basic.NET "The Round method with a single argument return the whole number nearest to the argument. If the argument to Round is midway between two whole numbers,
4
7254
by: Fuzzydave | last post by:
I have been using a round command in a few places to round a value to zero decimal places using the following format, round('+value+', 0) but this consistantly returns the rounded result of the value to one decimal place with a zero EG:
10
16034
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2) 0.74
7
4476
by: kkmigas | last post by:
Can some one explain if this can be fixed using php.ini settings ? echo "round 20.545 -".round(20.545,2)."<br>"; echo "round 20.555 -".round(20.555,2)."<br>"; echo "number_format 20.545 -".number_format(20.545, 2, ',', '.')."<br>"; echo "number_format 20.555 -".number_format(20.555, 2, ',', '.')."<br>"; PHP Version 4.3.0 / FreeBSD
3
1833
by: Krishna.K.1900 | last post by:
Does round() always perfectly return the output expected or are there some artifacts which don't allow perfect functionality Using python 2.5: 12.23 12.234 12.199999999999999 but was expecting 12.2
4
10894
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
9
6558
by: josh logan | last post by:
Hello, I need a round function that _always_ rounds to the higher integer if the argument is equidistant between two integers. In Python 3.0, this is not the advertised behavior of the built-in function round() as seen below: 0 2 2
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.