寫了幾行代碼,不知道哪個更好,
歡迎指導,呵呵
Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strCkb1 As String
Dim strCkb2 As String
strCkb1 = CInt(-ckb1.Checked).ToString
strCkb2 = CInt(-ckb2.Checked).ToString
Select Case strCkb1 & strCkb2
Case "00"
MsgBox("neither checked")
Case "10"
MsgBox("only checkbox1 checked")
Case "01"
MsgBox("only checkbox2 checked")
End Select
End Sub
Private Sub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ckb1.Checked And Not ckb2.Checked Then
MsgBox("only checkbox1 checked")
End If
If Not ckb1.Checked And ckb2.Checked Then
MsgBox("only checkbox2 checked")
End If
If Not ckb1.Checked And Not ckb2.Checked Then
MsgBox("neither checked")
End If
End Sub
說白了也就是想在有兩個條件的時候使用CASE
水平比較低,見笑了