for ...next语句和循环嵌套帮解释下好么

来源:百度知道 编辑:UC知道 时间:2024/06/25 21:20:26
option explicit
private sub command1_click()
dim i as integer
if list1.selcount=1 then
list1.removeitem list1.listindex
elseif list1.listcount > 1 then
for i = list1.listcount - 1 to 0 step -1
if list1.selected(i) then
list1.removeitem i
end if
next i
end if
end sub

希望能帮我把这个语句详细解释下``
我很笨``我会给我满意的答案加分的`希望各位朋友详细解答``
最好能给我找到一个比较好的教程和网站``谢谢`

option explicit '强制显式声明
private sub command1_click()
dim i as integer '定义i为整型变量
if list1.listIndex=1 then '间断是否选择第二项,是执行Then后面的语句
list1.removeitem list1.listindex '移除第二项内容
elseif list1.listcount > 1 then '判断列表框项目是否超过两项,有则执行Then后面的语句
Rem 移除列表框的所有内容,可以用list1.Clear语句替代下面的循环语句
for i = list1.listcount - 1 to 0 step -1
if list1.selected(i) then
list1.removeitem i '移除第i+1项的内容
end if
next i
end if
end sub