这行代码不会评估:
If(StrComp(Left("Campaign", 5), "IMS :") = 0
我这样使用它:
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
myVar = Application.Eval(strHolder)
这是我收到的错误:
Run-time error '2425': The expression you entered has a function name that Microsoft Access can't find.
我猜测Application.Eval
无法读取If
,StrComp
或Left
不知道该怎么做,我无法找到有关Eval
方法的详细信息。
答案 0 :(得分:3)
这行代码不会评估:
If(StrComp(Left("Campaign", 5), "IMS :") = 0
由于括号不平衡而且它不会编译,If
没有Then
。
此行还应该有编译错误......
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
如果你想要这样的立即窗口示例......
? StrComp(Left("Campaign", 5), "IMS :") = 0
False
...然后将您提交给"
的字符串中的Eval()
字符加倍...
strHolder = "StrComp(Left(""Campaign"", 5), ""IMS :"") = 0"
? strHolder
StrComp(Left("Campaign", 5), "IMS :") = 0
myVar = Application.Eval(strHolder)
? myVar
0
? CBool(myVar)
False