I am trying to verify that a string contains only known values. In this case, I need to make sure that it contains only “Shift”, “Control” or “Alt”, but not necessarily all of them. For example, this should be true: "Shift + P", "Shift + Control + H", "Alt + U", but it should not: "Other + P", "Shift + Fake + Y", "Unknown + Shift "+ E" etc.
This is the code I tried to use:
If Not shortcut.Contains("Shift") Or Not shortcut.Contains("Control") Or Not shortcut.Contains("Alt") Then
MessageBox.Show("Invalid")
End If
I have difficulty wrapping around the right logic for this. I guess there is a logical operator that can do this?
source
share