Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't this function work?? 1

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I want a ceiling function in classic .asp. I have written the function. Unfortunately when I call the function nothing happens. I am quite frustrated because I feel that I am overlooking something obvious.

Here is the call...

e = ceiling(99.2323)
response.write "this should print 100..." & e

Here is the function

Function ceiling(inputValue)
outputValue = 0
if int(inputValue) = inputValue then
outputValue=inputValue
else
outputValue= int(inputValue) + 1
end if
end Function

Currently, e does not print
 
You are using a function and so it looks like you are not actually returning anything. I think your problem may be that you just need to return the value you are creating like this...

Function ceiling(inputValue)
'I dont think you need to initalize an output variable
'unless you want to specifically show what you are doing
if int(inputValue) = inputValue then
ceiling =inputValue
else
ceiling = int(inputValue) + 1
end if
end Function
 
I had forgotten that the name of the thing you return is supposed to be the same as the function name. Thanks Jetar!
 
OhioSteve,

FYI.

The .NET framework contains a ceiling function located at System.Math.Ceiling ().

Keith
 
OhioSteve -
Like yu217171 says, the .NET framework often contains functions like Ceiling. It's often worthwhile to look through the MSDN before writing your own. So far, I've found that every general business-oriented thing I wanted to do, has been in the framework in some fashion.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top