将 eval() 声明为变量

declaring an eval() as a variable

我的活动服务器页面代码中有两个变量

昏暗 STATE_INSPECTIONDETAILLIBELLE_(1000) 昏暗 ERROR_INSPECTIONDETAILLIBELLE_(1000)

还有一个表格,其中包含我所有的变量和错误检查

some asp bla bla
do while not vrs.eof
    %>
    <tr>
    <td>
    <input type="text" name="inspectiondetailLibelle_<%=vrs("id")%>" value="STATE_<%=trim(vrs("id"))%>">
&nbsp;<%=ERROR_inspectiondetailLibelle_<%=vrs("id")%>
    </td>
</tr>

所以现在我正在检查字段是否为空而不是空的

if trim(eval("STATE_INSPECTIONDETAILLIBELLE_" & STATE_Param_Events))="" then                
   eval("ERROR_INSPECTIONDETAILLIBELLE_" & STATE_Param_Events)= "Erreur: Le libellé de la vérification ne peut pas être vide!"
 else
    update database bla bla
end if

我的问题是我的代码显然无法正常工作,出现错误

type mismatch: 'Eval' in line
eval("ERROR_INSPECTIONDETAILLIBELLE_" & STATE_Param_Events)= "Erreur: Le libellé de la vérification ne peut pas être vide!"

我如何构建我的变量 ERROR_ + 串联,以便我在我的表单中做正确的错误 response.write

谢谢 麦克

如果您需要为动态命名的变量赋值,请使用 execute 而不是 eval。像这样:

execute("ERROR_INSPECTIONDETAILLIBELLE_" & STATE_Param_Events & "=""Erreur: Le libellé de la vérification ne peut pas être vide!""")

请注意,使用 execute 并不安全,请考虑使用 Scripting.Dictionary