私は現在、非常によく似た2セットのif-elseステートメントを書いています。基本的に3つのドロップダウンメニューを比較し、ユーザーが2つの一致する設定を入力していないことを確認します。例えば:
cbo_fac1 - Kitchen
cbo_fac2 - Kitchen
cbo_fac3 - Lounge
cbo_fac1とcbo_fac2が一致するため、これはエラーメッセージを返します。しかし、私が実装するのに苦労している特別なケースのシナリオがあります。ドロップダウンのケースの1つは、設定なしです。
cbo_fac1 - Kitchen
cbo_fac2 - No preference
cbo_fac3 - No preference
cbo_fac1 - No preference
cbo_fac2 - No preference
cbo_fac3 - No preference
どのシナリオでも、優先順位の選択を一致させることはできません。これを実装するにはどうすればよいですか?これまでに使用しているコードは次のとおりです。
If cbo_fac1.Value = cbo_fac2.Value Then
MsgBox ("Facilities preference 1 and facilities preference 2 cannot be the same. Please select another option for facilities preference 2, if you have none then select 'No preference'")
Exit Sub
End If
If cbo_fac1.Value = cbo_fac3.Value Then
MsgBox ("Facilities preference 1 and facilities preference 3 cannot be the same. Please select another option for facilities preference 3, if you have none then select 'No preference'")
Exit Sub
End If
If cbo_fac2.Value = cbo_fac3.Value Then
MsgBox ("Facilities preference 2 and facilities preference 3 cannot be the same. Please select another option for facilities preference 3, if you have none then select 'No preference'")
Exit Sub
End If