您当前的位置: 首页 > 网站编程 > ASP教程 > ASP基础教程之学习ASP中子程序的应用

ASP基础教程之学习ASP中子程序的应用

作者:guanchaofeng 来源:不详 发布时间: 2009-03-24 17:21 点击:
在ASP中,你可通过VBScript和其他方式调用自程序。 实例: 调用使用VBScript的子程序 如何从ASP调用以VBScript编写的子程序。 html head % sub vbproc(num1,num2) response.write(num1*num2) end sub % /head body p You can call a procedure like this: /p

ASP基础教程之学习ASP中子程序的应用

在ASP中,你可通过VBScript和其他方式调用自程序。

实例:

调用使用VBScript的子程序
如何从ASP调用以VBScript编写的子程序。
 <html>

<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>

<body>
<p>
You can call a procedure like this:
</p>
<p>
Result: <%call vbproc(3,4)%>
</p>
<p>
Or, like this:
</p>
<p>
Result: <%vbproc 3,4%>
</p>
</body>

</html>
调用使用JavaScript的子程序
如何从ASP调用以JavaScript编写的子程序。
<%@ language="javascript" %><html><head><%function jsproc(num1,num2){Response.Write(num1*num2)}%></head><body><p>Result: <%jsproc(3,4)%></p></body></html>
调用使用VBScript和JavaScript的子程序
如何在一个ASP文件中调用以VBScript和JavaScript编写的子程序。
<html><head><%sub vbproc(num1,num2)Response.Write(num1*num2)end sub%><script  language="javascript" runat="server">function jsproc(num1,num2){Response.Write(num1*num2)}</script></head><body><p>Result: <%call vbproc(3,4)%></p><p>Result: <%call jsproc(3,4)%></p></body></html>

子程序

ASP源代码可包含子程序和函数:

<html><head><%sub vbproc(num1,num2)response.write(num1*num2)end sub%></head><body><p>Result: <%call vbproc(3,4)%></p></body></html>

将<%@ language="language" %>这一行写到<html>标签的上面,就可以使用另外一种脚本语言来编写子程序或者函数:

<%@ language="javascript" %><html><head><%function jsproc(num1,num2){Response.Write(num1*num2)}%></head><body><p>Result: <%jsproc(3,4)%></p></body></html>

VBScript与JavaScript之间的差异

当从一个用VBScript编写的ASP文件中调用VBScript或者JavaScript子程序时,可以使用关键词"call",后面跟着子程序名称。假如子程序需要参数,当使用关键词"call"时必须使用括号包围参数。假如省略"call",参数则不必由括号包围。假如子程序没有参数,那么括号则是可选项。

当从一个用JavaScript编写的ASP文件中调用VBScript或者JavaScript子程序时,必须在子程序名后使用括号。

分享到:
本文"ASP基础教程之学习ASP中子程序的应用"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4