ASP Subroutines
- Previous Page ASP Variables
- Next Page ASP Forms
In ASP, you can call subroutines using VBScript and other methods.
Example:
- Calling a subroutine using VBScript
- How to call a subroutine written in VBScript from ASP.
- Calling a subroutine using JavaScript
- How to call a subroutine written in JavaScript from ASP.
- Calling subroutines using VBScript and JavaScript
- How to call subroutines written in VBScript and JavaScript from an ASP file.
Subroutine
ASP source code can include subroutines and functions:
<html> <head> <% sub vbproc(num1,num2) response.write(num1*num2) end sub %> </head> <body> <p>Result:</p> <%call vbproc(3,4)%></p> </body> </html>
To set <%@ language="language" %> This line written above the <html> tag allows you to 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>
Differences between VBScript and JavaScript
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 the subroutine requires parameters, parentheses must enclose the parameters when using the keyword "call". If "call" is omitted, the parameters do not need to be enclosed in 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, parentheses must be used after the subroutine name.
- Previous Page ASP Variables
- Next Page ASP Forms