基于用户窗体中的多个复选框在文本框中显示文本字符串

Display string of text in textbox based on the multiple checkbox in userform

我创建了一个带有 4 个复选框和 1 个文本框的简单用户表单。

我希望能够根据单击的复选框显示句子。 如果 checkboxSwimming pool 被选中,我想显示这个字符串: 来电者提到了游泳池。

如果checkbox swimmingpool和checkbox balcony被选中,我想显示这个字符串。

来电者提到了游泳池。 来电者提到了阳台。

还有儿子。

到目前为止,这是我的代码:

Private Sub CommandButton1_Click()

'If chkPool.Value = True Then
'txtComment.Text = "The caller asked about Swimming Pool."

'ElseIf chkBalcony.Value = True Then
'txtComment.Text = "The caller asked about Balcony and Patio."

'End If

Select Case test_test

Case chkPool.Value = True
txtComment.Text = "The caller asked about Swimming Pool."


Case chkPool.Value = True & chkBalcony.Value = True
txtComment.Text = "The caller asked about Swimming Pool."
txtComment.Text = "The caller asked about balcony."


End Select




End Sub

这是您要找的吗?

Private Sub CommandButton1_Click()

txtComment.Text = ""

If chkPool.Value = True Then
    txtComment.Text = txtComment.Text & "The caller asked about Swimming Pool." & Chr(10)
End If

If chkBalcony.Value = True Then
    txtComment.Text = txtComment.Text & "The caller asked about Balcony and Patio." & Chr(10)
End If

'... add more IF clauses for the other check boxes here...


End Sub

只需确保文本框为 MultiLine = True