ASP Best Practices

Previous Topic Next Topic

Statement Styles

Each scripting language has its own conventions for capitalization, indentation, and other style-related characteristics. Since VBScript is case-insensitive, capitalization conventions can be devised to improve readability, as the following suggestions illustrate.

If…Then…Else…End If statements:

Correct example:

<%
  If Request("FName") = "" Then
    Response.Clear  'Not required if Response is buffered.
    Response.Redirect "test.html"
  Else
    Response.Write Request("FName")
  End If
%>

Similarly, capitalize the first letters of function and subroutine statements, and indent their definitions two spaces. 

Example:

Sub SessionOnStart
  Session("MyId") = Request.ServerVariables(…)
End Sub

Avoid underscores.

Example:

Dim FirstName, LastName

© 1997-1999 Microsoft Corporation. All rights reserved.