0

im currently working on a project to automate memo.

i want to know how can multiple checkbox result can show to a single checkbox

please see example below screenshot enter image description here If I check the checkbox dog, cat and mouse, it should show in the textbox as dog, cat, mouse respectively or, if i uncheck one of the checkbox it wont show in textbox

thank you so much for your help

1 Answer 1

1

The straightforward solution would be to put the following code into the module of the userform

Option Explicit
Private petsChecked(1 To 3) As String
Private Sub chCat_Click()
    checkPets chCat, 1, "Cat"
    fillChecked
End Sub

Private Sub chDog_Click()
    checkPets chDog, 2, "Dog"
    fillChecked
End Sub

Private Sub chMouse_Click()
    checkPets chMouse, 3, "Mouse"
    fillChecked
End Sub
Private Sub checkPets(fill As Boolean, pos As Byte, petName As String)
    If fill Then
        petsChecked(pos) = petName
    Else
        petsChecked(pos) = ""
    End If
End Sub
Private Sub fillChecked()
    TextBox1 = Join(petsChecked, " ")
    ' ListBox1.List = petsChecked   '  <= this is the code for a listbox
End Sub

Another advanced solution would be to use a class module for the check boxes similar to this example

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.