小弟请教简化问题
我是刚刚想学习VB6编程的,遇到一些困难,想请教高手指点。1.
在窗口中添加一个CommandButton按钮,添加20个CheckBox复选框,还有添加一个ListBox列表框,
在CommandButton按钮填入下面的代码
Private Sub Command1_Click()
If Check1.Value = 1 Then List1.AddItem Check1.Caption
If Check2.Value = 1 Then List1.AddItem Check2.Caption
If Check3.Value = 1 Then List1.AddItem Check3.Caption
If Check4.Value = 1 Then List1.AddItem Check4.Caption
If Check5.Value = 1 Then List1.AddItem Check5.Caption
If Check6.Value = 1 Then List1.AddItem Check6.Caption
If Check7.Value = 1 Then List1.AddItem Check7.Caption
If Check8.Value = 1 Then List1.AddItem Check8.Caption
If Check9.Value = 1 Then List1.AddItem Check9.Caption
If Check10.Value = 1 Then List1.AddItem Check10.Caption
If Check11.Value = 1 Then List1.AddItem Check11.Caption
If Check12.Value = 1 Then List1.AddItem Check12.Caption
If Check13.Value = 1 Then List1.AddItem Check13.Caption
If Check14.Value = 1 Then List1.AddItem Check14.Caption
If Check15.Value = 1 Then List1.AddItem Check15.Caption
If Check16.Value = 1 Then List1.AddItem Check16.Caption
If Check17.Value = 1 Then List1.AddItem Check17.Caption
If Check18.Value = 1 Then List1.AddItem Check18.Caption
If Check19.Value = 1 Then List1.AddItem Check19.Caption
If Check20.Value = 1 Then List1.AddItem Check20.Caption
End Sub
2。
将上面的代码简化成下面的运行时提示出错:编译错误 子程序或函数未定义
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To 19
If check(i).Value = True Then List1.AddItem check(i).Caption
Next i
End Sub
我想不是这样简化吧,1。的代码不是循环,2.的代码是循环
也不知道是否,小弟刚学VB 想请教高人指点
小弟在此谢过了!