【发布时间】:2011-05-16 19:18:43
【问题描述】:
我正在尝试验证字符串是否只包含已知值。在这种情况下,我需要确保它只包含“Shift”、“Control”或“Alt”,但不一定包含所有这些。例如,这些应该是真的:“Shift + P”、“Shift + Control + H”、“Alt + U”;但这些不应该是:“Other + P”、“Shift + Fake + Y”、“Unknown + Shift + E”等
这是我尝试使用的代码:
If Not shortcut.Contains("Shift") Or Not shortcut.Contains("Control") Or Not shortcut.Contains("Alt") Then
MessageBox.Show("Invalid")
End If
我很难理解执行此操作所需的逻辑。我假设有一个逻辑运算符可以做到这一点?
【问题讨论】: