Returning a value from a function

N

neptune6644

I'm having trouble getting the following function to return a value,
unless I add a response.write to the end of the function. Calling the
function will not get the value to appear.

<%

Dim strMyVar1, strMyVar2, poop

strMyVar1 = 75.5
strMyVar2 = 5.5

'----------------------------------------------------------------------------------------
'Why isn't this displaying a returned value?!?
'----------------------------------------------------------------------------------------
Response.Write per_to_dec(strMyVar1) & "<br>"


FUNCTION per_to_dec(poop)

if len(poop) = 1 then
poop = ".0" & strPer_to_Dec
end if

'ex. 47%
if len(poop) = 2 then
poop = "." & poop
end if

'ex 1.5%
if len(poop) = 3 AND mid(poop,2,1) = "." then
poop = Replace(poop,".","")
poop = ".0" & poop
end if

'ex. 1.75% or 17.5%
if len(poop) = 4 then
if mid(poop,2,1) = "." then
poop = Replace(poop,".","")
poop = ".0" & poop
elseif mid(poop,3,1) = "." then
poop = Replace(poop,".","")
poop = "." & poop
end if
end if

'ex. 10.75%
if len(poop) = 5 then
poop = Replace(poop,".","")
poop = "." & poop
end if


'----------------------------------------------------------------------------------------
'This is the only way this function will display a returned value

'----------------------------------------------------------------------------------------
response.write poop
END FUNCTION
%>

What am I doing wrong?

Thanks.
 
M

McKirahan

I'm having trouble getting the following function to return a value,
unless I add a response.write to the end of the function. Calling the
function will not get the value to appear.

[snip]

You have to set the name of the Function to your return value
before "End Function":

per_to_dec = poop
 
N

neptune6644

McKirahan said:
I'm having trouble getting the following function to return a value,
unless I add a response.write to the end of the function. Calling the
function will not get the value to appear.

[snip]

You have to set the name of the Function to your return value
before "End Function":

per_to_dec = poop

Yep! Thanks. Was just coming back to post a "nevermind." I finally saw
what was wrong. it's been a loooooooooooooong day. hehe

Thanks for the reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top