ASP Q&A: Commenting Blocks in VBScript

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

This is the third in a series of tips being posted based on the most read posts in one of our ASP Forums. (previous Q&A)

Problem / Question:

How can a whole block of VBScript be commented out?


Unfortunately, you cannot block comment VBScript like you can in other languages. You can comment out each line individually. Just put a single quotation mark at the start of the line you want to ‘out’ and do then do the same for each subsequent line.

The following shows a sample code listing with a block of code commented:

Dim a, iLen, bSpace, tmpX, tmpFull

iLen = Len(sText)
  For a = 1 To iLen
'    If a <> 1 Then
'        If bSpace = True Then
'            tmpX = UCase(mid(sText,a,1))
'            bSpace = False
'        Else
'        tmpX=LCase(mid(sText,a,1))
'            If tmpX = " " Or tmpX = "'" Then bSpace = True
'        End if
'    Else
'        tmpX = UCase(mid(sText,a,1))
'    End if 
tmpFull = tmpFull & tmpX Next ProperCase = tmpFull End Function

Based on posts by forum members Lydia, Scotty, and Xanderno

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read