Latest web development tutorials

ASP program

In ASP, you can call a JavaScript procedure by VBScript, and vice versa.


Subroutine

ASP source code can contain subroutines and functions:

Examples

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

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

</body>
</html>

The demonstration >>

The<% @ language = "language"%> This line written in the above <html> tag, you can use another scripting language to write a subroutine or function:

Examples

<%@ language="javascript" %>
<!DOCTYPE html>
<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>

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

</body>
</html>

The demonstration >>


Different VBScript and JavaScript,

When calling a VBScript or a JavaScript procedure from an ASP file written in VBScript, you can use the "call" keyword followed by the procedure name. If a procedure requires parameters when using the "call" keyword, the parameter must be enclosed in parentheses. If you omit the "call" keyword, the parameters need not be included in parentheses. If the procedure has no parameters, the parentheses are optional.

When calling a VBScript or a JavaScript procedure from an ASP file written in JavaScript, you must use parentheses after the subroutine name.


Examples

More examples

Using VBScript subroutine call
This example demonstrates how to call a VBScript routines and subroutines in an ASP JavaScript document.