Chapter 44: VBScript Keywords

1. What are “VBScript Keywords”?

VBScript keywords are the reserved words that have special meaning in the VBScript language.

You cannot use them as variable names, function names, or Sub names — if you do, you get a syntax error.

They are the building blocks of the language — they control flow, declare variables, handle errors, define loops, conditions, etc.

There are about 100 keywords in total, but in real Classic ASP code you only use ~30–40 regularly.

W3Schools lists them in their VBScript reference, but they do not explain them in detail in one place — so today I will give you the practical, production-oriented overview.

2. The Most Important Categories & Keywords (with Real Examples)

I will group them the way real developers think about them — not alphabetical, but by how often you actually use them.

A. Variable & Procedure Declaration (You use these every single day)

Keyword Purpose Real Example in Classic ASP
Dim Declare a variable Dim name, age, total
Const Declare a constant (cannot change) Const TAX_RATE = 18
Private Declare variable/sub/function private (rare in ASP) Private Sub MyHelper()
Public Declare public (default in ASP) Rarely needed
Sub Define a subroutine (no return value) Sub ShowHeader()
Function Define a function (returns value) Function FormatPrice(amount)
End Sub End of subroutine
End Function End of function

Real example:

asp

B. Conditional Statements (Decision making)

Keyword Purpose Real Example
If … Then … Else … ElseIf … End If If-else chain If age >= 18 Then … Else … End If
Select Case … Case … Case Else … End Select Multi-value switch Select Case day … Case 1 … End Select

Real example:

asp

C. Looping Statements (Repeating code)

Keyword Purpose Real Example
For Each … In … Next Loop over collection/array For Each item In products … Next
For … To … Step … Next Counter-based loop For i = 1 To 10 Step 2 … Next
Do While … Loop Loop while condition true Do While Not rs.EOF … Loop
Do Until … Loop Loop until condition true Do Until rs.EOF … Loop
Do … Loop While Check condition after first run Do … Loop While condition
Do … Loop Until Check after first run Do … Loop Until condition
Exit Do Break out of Do loop
Exit For Break out of For loop

Real example (database loop — very common):

asp

D. Error Handling (Very important in Classic ASP)

Keyword Purpose Real Example
On Error Resume Next Ignore errors and continue Very common — but dangerous if overused
On Error GoTo 0 Turn error handling off Reset after risky block
Err.Number Last error code If Err.Number <> 0 Then …
Err.Description Error message
Err.Clear Clear current error After handling

Real example:

asp

E. Other Very Common Keywords

Keyword Purpose Real Example
Option Explicit Force variable declaration (MUST USE) <%@ Option Explicit %> at top of every page
Call Call a Sub (optional) Call ShowHeader() or just ShowHeader
Set Assign object reference Set conn = Server.CreateObject(“ADODB.Connection”)
Nothing Release object Set rs = Nothing
Is Nothing Check if object is not set If conn Is Nothing Then …
Is Empty Check if variable is uninitialized If IsEmpty(value) Then …
IsArray Check if variable is array
Redim Resize dynamic array Redim Preserve arr(10)
Erase Clear array Erase arr

6. Teacher Summary – VBScript Keywords in Classic ASP

VBScript Keywords are the reserved words that control the language:

  • Declaration: Dim, Const, Sub, Function, End Sub, End Function
  • Conditions: If … Then … Else … End If, Select Case … End Select
  • Loops: For Each … Next, For … To … Next, Do While/Until … Loop
  • Error handling: On Error Resume Next, Err.Number, Err.Description
  • Objects: Set, Nothing, Is Nothing
  • Others: Option Explicit (always use!), Call, Redim, Erase, IsArray, IsEmpty

Always use Option Explicit at the top of every .asp file — it prevents hundreds of silent bugs.

These keywords are the building blocks of every Classic ASP page — and many legacy Indian systems still use exactly this keyword set in 2026.

Next class?

  • Want a full example combining loops, conditions, functions, error handling?
  • Or common VBScript gotchas with keywords (case-insensitivity, Variant type)?
  • Or compare VBScript keywords vs modern VB.NET / C#?
  • Or move to the next W3Schools topic (ASP Redim or ASP Date Functions)?

Just tell me — I’m here! 🚀🇮🇳 Keep learning strong, Webliance! 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *