469,902 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Getting a return value from a sub/function in asp

101 100+
Do ASP subroutines have this? How about functions? And, what's the difference between asp subroutines and functions?

Thanks for any help.
Oct 3 '07 #1
2 1791
markrawlingson
346 Expert 100+
Subroutines in ASP do not return values. They exist only to perform repetitive tasks. Subroutines also cannot take an object as an argument. So if I wanted to pass a recordset object to a subroutine and have it perform a certain task on it, I wouldn't be able to.

Functions on the other hand do return a value and are use to more or less calculate things or return results. Functions, unlike subroutines, CAN take an object as an argument and therefore manipulate that object.

For instance, I wrote a simple function in order to close a recordset, because I'm lazy.

Example of a function returning a value
Expand|Select|Wrap|Line Numbers
  1. Function Devide(iNum1,iNum2)
  2.    iTemp = Num1/Num2
  3.    Devide = iTemp
  4. End Function
  5.  
It takes two arguments, both numbers - devides the numbers, and returns the result by setting the function name ("Devide" in this case) equal to the result, therefore returning the function

Devide(2,2) will return 1

Sincerely,
Mark
Oct 4 '07 #2
zensunni
101 100+
Wow, you explained everything I needed to know. Thanks!
Oct 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

41 posts views Thread by Jim | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.