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 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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.