根据userform中的多个checkbox显示文本框中的文本string

我用4个checkbox和1个文本框创build了一个简单的用户窗体。

在这里输入图像说明

我希望能够显示基于点击checkbox的句子。 如果checkboxSwimming池是检查,我想显示这个string:来电者提到关于游泳池。

如果checkbox游泳池和checkbox阳台是检查,我想显示这个string。

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

和儿子。

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

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