电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Asp>>The Real Basics of Functions in ASP - Simplemaths:

The Real Basics of Functions in ASP - Simplemaths

来源:www.cncfan.com | 2006-1-25 | (有2026人读过)

(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)
%>

Asp热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号