<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>
<%@ language=javascript %> <html> <head> <% function jsproc(num1,num2) { Response.Write(num1*num2)}%></head><body><p>Result: <%jsproc (3,4)%></p></body></html>
<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 basic tutorial for learning the application of ASP neutron programs
ASP source code can contain subroutines and functions:
<html> <head><%sub vbproc(num1,num2)response.write(num1*num2)end sub%></head><body><p>Result: <%call vbproc(3,4)%> </p></body></html>
By writing the line <%@ language=language %> above the <html> tag, you can use another scripting language to write subroutines or functions:
<%@ language=javascript %> <html> <head> <% function jsproc(num1,num2) { Response.Write(num1*num2) } %> </head> <body> <p>Result: <%jsproc (3,4)%></p> </body> </html>
When calling a VBScript or JavaScript subroutine from an ASP file written in VBScript, you can use the keyword call, followed by the subroutine name. If a subroutine requires parameters, the parameters must be surrounded by parentheses when using the call keyword. If call is omitted, the parameters do not need to be surrounded by parentheses. If the subroutine has no parameters, the parentheses are optional.
When calling a VBScript or JavaScript subroutine from an ASP file written in JavaScript, you must use parentheses after the subroutine name.