分类广告


推荐文章

  • 没有找到任何内容!
您当前的位置:中国站长下载网络编程ASP专区 → 文章内容

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

  • 作者:不详    来源:网络转载    发布时间:2007-11-13 13:04:05
  • 字体大小:

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

中.国.站.长.站

实例: 中国站.长.站

调用使用VBScript的子程序

Www@Chinaz@com

如何从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>

Chinaz^com

调用使用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>标签的上面,就可以使用另外一种脚本语言来编写子程序或者函数:

Chinaz^com

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

Www@Chinaz@com

Chinaz@com

VBScript与JavaScript之间的差异 站.长.站

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

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

Chinaz@com