Alright, here's the case.
Imagine that there's a rectangle with 4 points on it, naming rodUpLeft, rdoUpRight, rdoDownLeft, rdoDownRight as checkbox
I want to make sure that there's exactly TWO checked box checked AT ALL TIMES
Kind of like how radio button works, except instead of just one button got checked, I want two.
So I've tweaked around and came up with a code as below
If sender.name = firstChoice Then
sender.checked = True
ElseIf Not lastChoice = sender.name Then
Select Case lastChoice
Case "rdoUpRight"
rdoUpRight.Checked = False
Case "rdoUpLeft"
rdoUpLeft.Checked = False
Case "rdoDownRight"
rdoDownRight.Checked = False
Case "rdoDownLeft"
rdoDownLeft.Checked = False
End Select
lastChoice = firstChoice
firstChoice = sender.name
End If
So my initially idea is to track the buttons that were clicked, and uncheck the old button when a new unchecked button is clicked.
However, it does not stop the user from unchecking already checked checkbox, thus breaking the rest of the code.
A help would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire