If RB_Male.Checked Or RB_Female.Checked = False Then
MessageBox.Show("Please select your gender")
ElseIf RB_Male.Checked = False Or RB_Female.Checked = True Then
ElseIf RB_Male.Checked = True Or RB_Female.Checked = False Then
End If
我有一个问题,我希望我的错误信息仅在未选择两个单选按钮时弹出。上面的代码允许消息框弹出,即使选择了一个我不想要的单选按钮。任何帮助将不胜感激。
答案 0 :(得分:1)
检查是否未选中任何按钮:
If Not (RB_Male.Checked AndAlso RB_Female.Checked) Then
答案 1 :(得分:0)
If (NOT RB_Male.Checked) ANDALSO (NOT RB_Female.Checked) Then
MessageBox.Show("Please select your gender")
ElseIf RB_Male.Checked = False Or RB_Female.Checked = True Then
ElseIf RB_Male.Checked = True Or RB_Female.Checked = False Then
End If