472,110 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 1822
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

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.