来源:www.cncfan.com | 2006-1-25 | (有2156人读过)
(Page 2 of 5 )
Ok, pretty simple – so let’s complicate this one with by wrapping it up in a function called "simplemaths." Let’s look at the function protocol first:
<% function simplemaths(var1, var2)
end function %>
We’ve created a function (which doesn’t actually do anything yet). It needs two input variables (var1 and var2). We would then use the following code to call the function if both of our variables equalled 3 and 2:
<% call simplemaths(3, 2) %>
Simple, right? All that we need now is to edit our function so that it actually does something! Just as the customer requested, the function will simply add our two values together and produce the result on screen.
<% 'Define our function function simplemaths(var1, var2) result=var1+var2 response.write result & "<br />" end function
'run the function call simplemaths(3, 2) %>
Note that var1 and var2 are the variable names within the function and not outside it. You could choose to use variables outside of the function too. To add 10 and 20 together using variables:
<% 'Define our function function simplemaths(var1, var2) result=var1+var2 response.write result & "<br />" end function
input1=10 input2=20
call simplemaths(input1, input2) %>
|