VBA中是否有NotIn("A","B")功能?

Pow*_*ser 1 ms-access vba access-vba

我正在编写一个需要输入的函数,我的数据验证看起来很尴尬.如果InputFld不是"A","B"或"C",则表示错误:

If InputFld <>"A" and InputFld<>"B" and InputFld<>"C" then goto ErrorHandler

这对我来说太丑了.有更优雅的解决方案吗?我想写一些类似的东西:

If InputFld not in ("A","B","C") then goto ErrorHandler

看到?这种方式更容易阅读和维护.但我不知道该怎么做.

Fio*_*ala 5

怎么样:

If Instr("ABC",InputFld)=0 Then
Run Code Online (Sandbox Code Playgroud)

  • 其他答案让我想起了一个Monty Python短剧,他们用火箭筒进行蚊子狩猎. (2认同)