2

Is there any way how to add comments to end of each line in longer multi-line expression in ASP (using VBScript)? I have code like this:

    Dim qbsr As New QueryBuilder(conn)
    qbsr.Select = "Items.ItemCode as ItemCode,Items.Description as Descr, " & _ 
    "Items.Class_03 as UnitType, " & _  ' ** Cannot add comment here **
    "Items.Class_04 as UnitPlc, " & _  ' ** Cannot add comment here **
    "Items.Class_05 as UnitArea" ' Comment here works fine

I found similar question, however all answers were about multi-line comments and not adding comments at the end of each lines in multi-line expression.

Community
  • 1
  • 1
Ondřej Šotek
  • 1,793
  • 1
  • 15
  • 24

2 Answers2

5

You can't add comments in the middle of a logical line of code, even if you break it up into multiple physical lines on your screen. If you absolutely must have comments in the middle, you'll need to break the code itself into chunks.

q = "Items.ItemCode as ItemCode, Items.Description as Descr, " '- comment goes here
q = q & "Items.Class_03 as UnitType, " '- comment goes here
q = q & "Items.Class_04 as UnitPlc, "  '- comment goes here
q = q & "Items.Class_05 as UnitArea"   '- comment goes here
qbsr.Select = q

(Note that VBScript is pretty bad at string concatenation, so this sort of code can be pretty slow - basically, don't put it into a loop.)

Martha
  • 3,932
  • 3
  • 33
  • 42
1

No, unfortunately you cannot add comments to the end of each line, only the last line.

Keith
  • 20,636
  • 11
  • 84
  • 125