472,354 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Returning a value from a function

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.

Sep 29 '06 #1
2 1076
<ne*********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
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
Sep 29 '06 #2

McKirahan wrote:
<ne*********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
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.

Sep 29 '06 #3

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

Similar topics

2
by: Mountain Man | last post by:
Hi, I'm having trouble with the foreach function. I'm using it twice inside a user defined function with two different arrays, and in the second instance it's returning the value of the first...
6
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return...
9
by: mjm | last post by:
Folks, Stroustrup indicates that returning by value can be faster than returning by reference but gives no details as to the size of the returned object up to which this holds. My question is...
18
by: cppaddict | last post by:
Hi, Is it considered bad form to have the subscript operator return a const reference variable? If not, what is the proper way to do it? My question was prompted by the code below, my...
9
by: Thomas Mlynarczyk | last post by:
Hi, It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
8
by: sam | last post by:
i am starting to experiment with recursion, and decided to write a fairly trivial little program which took a float as input, then called a function to halve it recursively until it was less than...
8
by: Michal Nazarewicz | last post by:
Hi, What does returning 0 from main() mean according to C89/C90 standard? I've found that in C99 it means successful termination (7.20.4.3p5) however as I'm editing book on C at Polish Wikibooks...
2
by: Drew | last post by:
I am trying to build a page to generate some random data for a database that I am working on... I thought this would be simple, but it has proven to be more difficult... I am trying to create some...
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

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.