问个简单的问题,有点迷惑
窗体上有CheckBox控件数组,共六个,一个Command控件,一个TextBox控件,我用TextBox显示我选择了哪几个CheckBox,但是有个问题,为什么总要先选择最后一个CheckBox,也就是Check1(5)时TextBox中才会有显示我选中的哪几个,如果选其他的,不选Check1(5),TextBox中将显示 "No Append "
Private Sub Command1_Click()
Dim str As String
Dim i As Long
For i = 0 To 5
If Check1(i).Value = 1 Then
str = str & Check1(i).Caption & ", "
Text1.Text = str
Else
Text1.Text = "No Append "
End If
Next
End Sub
[解决办法]
Private Sub Command1_Click()
Dim str As String
Dim i As Long
Text1.Text = " "
For i = 0 To 5
If Check1(i).Value = 1 Then
str = str & Check1(i).Caption & ", "
'Text1.Text = str
Else
Text1.Text = "No Append "
End If
Next
if Text1.Text = " " then
Text1.Text = str
end if
End Sub
[解决办法]
仔细一点就行了`