Error Variable is undefined - ASP Errors

Description

Current variable has not being declared yet, before being used for its first time.

Error Message

English Error Message

Microsoft VBScript runtime  error '800a01f4'
Variable is undefined: 'variablename'
/path/to/file.asp, line 10

Error Variable is undefined

It is not a particularly critical error.
This message informs us that we are trying to use a variable without having declared it previously.

ASP, by default, does not oblige to declare the variables before using them, as, during the interpretation phase, the webserver automatically provides to identify all the variables used inside the code in order to allocate the necessary space for them.

In any case, it is good habit to get used to declare any variable before its use.
A declared variable improves the elaboration performance of the page and it allows to edit errors when calling non defined values.

How to Fix the Error

This error is only sent back in the case where the compulsory declaration was forced, through the Option Explicit instruction inserted at the beginning of the page.

To correct the error it is enough to define the variable before using it, through the Dim statement, as follows

Dim variablename 

where variablename is the variable we are dealing with.

It is recommended to always work with forced declaration property turned on as it will help the programmer to produce a safer, more efficient and performing code.


ASP.weppos.com and ASP.weppos.it are property of Simone Carletti.
Discover my website or visit my Simone Carletti's profile on LinkedIn