Function NameOfFunction(parameter1, parameter2)
NameOfFunction = "returnvalue"
You will notice above parameter1and parameter2. Data ispassed into a procedurethrough the use of thesearguments. Arguments areseparated by commas andput into parenthesis afterthe procedure name.
If there are no arguments,the procedure would stillhave the parenthesis, butthey would be empty:
'code goes here...
Belowis subprocedure that printsout details on the page:
To call the Sub, I coulddo one of the following:
Call PrintOut("michael","34 Hark Avenue","Ireland")
PrintOut "michael","34 HarkAvenue","Ireland"
Note that in each example,the actual argument passedinto the subprocedure ispassed into the subprocedurein the corresponding position.
Also note that if you usethe Call statement, thearguments must be enclosedin parenthesis. If you donot use call, the parenthesisaren't used.
Likethe Sub procedure, a Functioncan accept arguments, butunlike the Sub procedure,a Function can return avalue. Functions are especiallygood for doing calculationsand returning a value.
This is how the functionwas called:
Callingthe Total function madethe value of Total equalto the value returned bythe function, which thencan be displayed by doing
<%response.write Sum %>
Theoutput of the above is:102
Notethat the returned valueis named the same as thefunction.
This is important to remember!You will need to name theoutput value the same asyour function or you willnot get a value returned.
Codefixer- Tutorials and resourcesfor the beginner to intermediateASP developer.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Web Development Articles
More By Developer Shed