大家早上好,下午好:
我在 VBA 中有这样一个声明:
Select Case MAAX(Fila, 1)
Case Is <> 5, Is <> 10, Is <> 15, Is <> 20, Is <> 25, Is <> 30, Is <> 35, Is <> 40
Do whatever
End Select
但它不起作用..有什么问题?
如果“不工作”是指CASE
始终执行您后面的语句,则您可能误解了该语句的工作原理:
如果 testexpression 与ANY Case expressionlist 表达式匹配,则执行该 Case 子句后面的语句...
几乎无论 in 是什么MAAX(Fila, 1)
,它肯定会匹配至少一个你的子句。
您需要重写您的 CASE 语句(或使用其他东西),以测试您真正想要的逻辑。
如果您真正想要的是您的 testvalue 不是这些 (5, 10, ...) 中的任何一个,您可以执行类似的操作
if v<>5 and v<>10 and v<>15 ...
或者,可能
select case v mod 5
case is <>0 'then it is not one of those in your list,
'but it could be greater than 40, so you might have to test for that
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句