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

How to add comments to end of each line in multi-line expression in ASP?

在 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

我找到了 similar question,但是所有答案都是关于多行注释的,而不是在多行表达式的每行末尾添加注释。

不,很遗憾,您不能在每一行的末尾添加注释,只能在最后一行添加注释。

您不能在逻辑代码行的中间添加注释,即使您在屏幕上将它分成多行物理代码也是如此。如果您绝对必须在中间添加注释,则需要将代码 本身 分成块。

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

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