</>
Skip to content
ASP lessons (10/40)

ASP — Procedures

Sub

<%
Sub Greet(name)
    Response.Write("Hello, " & name & "!")
End Sub

Greet("John")
Greet("Jane")
%>

Function

<%
Function Add(a, b)
    Add = a + b
End Function

Dim result
result = Add(5, 3)
Response.Write(result)
%>

Return Value

<%
Function IsEven(num)
    If num Mod 2 = 0 Then
        IsEven = True
    Else
        IsEven = False
    End If
End Function

If IsEven(4) Then
    Response.Write("Even")
End If
%>

Scope

<%
' Global variable
Dim globalVar
globalVar = 10

Sub MySub()
    ' Local variable
    Dim localVar
    localVar = 5
    Response.Write(globalVar)  ' Can access global
End Sub
%>

Mini Practice

  1. Create a Sub
  2. Create a Function
  3. Return values
  4. Use variable scope

Up Next

Continue with Forms — working with forms.

Related Topics

Frequently Asked Questions about Procedures

What is Procedures in ASP?

Procedures is a fundamental concept in ASP. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Procedures?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Procedures.

Why is Procedures important in ASP?

Procedures is essential for ASP development. Understanding this concept will help you write better code and solve real-world problems more effectively.