One of the most common mistakes developers can make is to extensively use global variables. While they are sometimes necessary, global variables can cause problems in code that are both difficult to find and costly to fix. One way of preventing the use of global variables is by encapsulating all of your code in subroutines.
As in the code fragment below, ASP pages can be organized into a set of functions, all called from a Main subroutine declared at the top of the page. Using this coding standard can prevent debugging later.
<%@ LANGUAGE="VBSCRIPT" %> <% Main '----------------'Function: Main 'Purpose: Entry point for the page.'
---------- Sub Main %><% DisplayPage() %> <% End Sub %>