因为checkbox默认的操作是点一次选中,点两次取消选中,所以要修改代码,加一个布尔变量标记
修改后的代码如下:
Dim flag As Boolean
Private Sub CheckBox1_Click()
flag = False
If flag = False Then
CheckBox1.Value = 1
CheckBox2.Value = 0
CheckBox3.Value = 0
CheckBox4.Value = 0
flag = True
End If
End Sub
Private Sub CheckBox2_Click()
If flag = True Then
CheckBox1.Value = 0
CheckBox2.Value = 1
CheckBox3.Value = 0
CheckBox4.Value = 0
flag = False
End If
End Sub
Private Sub CheckBox3_Click()
If flag = False Then
CheckBox1.Value = 0
CheckBox2.Value = 0
CheckBox3.Value = 1
CheckBox4.Value = 0
flag = True
End If
End Sub
Private Sub CheckBox4_Click()
If flag = True Then
CheckBox1.Value = 0
CheckBox2.Value = 0
CheckBox3.Value = 0
CheckBox4.Value = 1
flag = False
End If
End Sub