登陆 免费注册 提交网站
站长资讯 >> 站长学院 >> 网络编程
 2007-08-17 10:27浏览: 2435 次

学习ASP中子程序的应用

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

实例:

调用使用VBscript的子程序

如何从ASP调用以VBscript编写的子程序。

<%

sub vbproc(num1,num2)

response.write(num1*num2)

end sub

%>

You can call a procedure like this:

Result: <%call vbproc(3,4)%>

Or, like this:

Result: <%vbproc 3,4%>

调用使用Javascript的子程序

如何从ASP调用以Javascript编写的子程序。

<%@ language="javascript" %>

<%

function jsproc(num1,num2)

{

Response.Write(num1*num2)

}

%>

Result: <%jsproc(3,4)%>

调用使用VBscript和Javascript的子程序

如何在一个ASP文件中调用以VBscript和Javascript编写的子程序。

<%

sub vbproc(num1,num2)

Response.Write(num1*num2)

end sub

%>

function jsproc(num1,num2)

{

Response.Write(num1*num2)

}

Result: <%call vbproc(3,4)%>

Result: <%call jsproc(3,4)%>

子程序

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

<%

sub vbproc(num1,num2)

response.write(num1*num2)

end sub

%>

Result: <%call vbproc(3,4)%>

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

<%@ language="javascript" %>

<%

function jsproc(num1,num2)

{

Response.Write(num1*num2)

}

%>

Result: <%jsproc(3,4)%>

VBscript与Javascript之间的差异

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

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

网站首页 - 关于我们 - 联系我们 - 友情链接 - 帮助中心
Copyright ©2007-2022 www.Aisila.com All Rights Reserved
苏ICP备20008864号-4