如何在ASP中的多行表达式中添加注释到每行的结尾?

Ond*_*tek 2 vbscript asp-classic

有没有办法如何在ASP中使用更长的多行表达式(使用VBScript)向每行的末尾添加注释?我有这样的代码:

    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
Run Code Online (Sandbox Code Playgroud)

我发现了类似的问题,但所有答案都是关于多行注释而不是在多行表达式的每行末尾添加注释.

Mar*_*tha 5

您无法在逻辑代码行的中间添加注释,即使您将其分解为屏幕上的多个物理行.如果你绝对必须在中间有评论,你需要将代码本身分解成块.

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
Run Code Online (Sandbox Code Playgroud)

(请注意,VBScript在字符串连接方面非常糟糕,因此这种代码可能非常慢 - 基本上,不要将它放入循环中.)