Private Sub Command1_Click()
Dim i As Integer, j As Integer
For i = 1 To 10
j = i + j
List1.AddItem j
Next i
For i = 1 To 4
List1.RemoveItem List1.ListCount - i
Next i
End Sub
每句都帮我解释一下好吗 详细一点 谢谢了
Private Sub Command1_Click()
Dim i As Integer, j As Integer
For i = 1 To 10
j = i + j
List1.AddItem j
Next i
For i = 1 To 4
List1.RemoveItem List1.ListCount - i
Next i
End Sub
每句都帮我解释一下好吗 详细一点 谢谢了
Private Sub Command1_Click() '按钮单击事件
Dim i As Integer, j As Integer '定义两个integer变量
For i = 1 To 10 'i的for循环,从1到10
j = i + j '为j赋值
List1.AddItem j '为list1中添加一项j
Next i '循环结束
For i = 1 To 4 '新循环
List1.RemoveItem List1.ListCount - i '删除总数-i那项
Next i '循环结束
End Sub '事件结束
一开始j=0
第一个循环
j=1+0=1 添加1
j=2+1=3
j=3+3=6
......
以此类推直i=10
list1内共10项
第二个循环每循环一次删除一个共循环四次,删除四个 至于删除哪六个自己推下吧
注意list是从0开始标记的,而个数不是
结果还有6个
list1显示
1
3
6
15
28
45
Private Sub Command1_Click()
Dim i As Integer, j As Integer
For i = 1 To 10
j = i + j
List1.AddItem j '这里是添加(添加10项)
Next i
For i = 1 To 4
List1.RemoveItem List1.ListCount - i '这里是删除(删除4项)
Next i
End Sub
所以只剩6项了。
Private Sub Command1_Click() //Command1的点击事件 Dim i As Integer, j As Integer //分别定义一个整型的i和j For i = 1 To 10 //开始循环操作,使i从1到10递变循环执行代码 j = i + j //把每次i循环的值加上j的总和赋值给j自己 List1.AddItem j //把得到的新j值添加到List1容器里 Next i For i = 1 To 4 //开始循环操作,使i从1到4递变循环执行代码 List1.RemoveItem List1.ListCount - i //从List1里移除(List1.ListCount - i)项数据,即List1的总行数-1
Next i
End Sub //结束