ASP Best Practices

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.

IfThenElseEnd If statements:

  • Capitalize the first letter of If , Then , Else , and EndIf .

  • Indent the statements following If , Then , or Else two spaces.

  • Put spaces at each end of an equal (=) sign.

  • Avoid using unnecessary parentheses.

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