| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1135 人关注过本帖
标题:小问题3
只看楼主 加入收藏
一叶秋
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2004-4-21
收藏
 问题点数:0 回复次数:2 
小问题3
Private Sub Form_Click() Dim Entry, I, Msg '声明变量。 Msg = "Choose OK to add 100 items to your listbox." MsgBox Msg '显示信息。 For I = 1 To 100 '计数值从1到100。 Entry = "Entry" & I '创建输入项。 List1.AddItem Entry '添加该输入项。 Next I Msg = "Choose OK to remove every other entry." MsgBox Msg '显示信息。 For I = 1 To 50 '确定如何 List1.RemoveItem I '每隔一项 Next I '删除。 Msg = "Choose OK to remove all items from the listbox." MsgBox Msg '显示信息。 List1.ClePrivate Sub Form_Click() Dim Entry, I, Msg '声明变量。 Msg = "Choose OK to add 100 items to your listbox." MsgBox Msg '显示信息。 For I = 1 To 100 '计数值从1到100。 Entry = "Entry" & I '创建输入项。 List1.AddItem Entry '添加该输入项。 Next I Msg = "Choose OK to remove every other entry." MsgBox Msg '显示信息。 For I = 1 To 50 '确定如何 List1.RemoveItem I '每隔一项 Next I '删除。 Msg = "Choose OK to remove all items from the listbox." MsgBox Msg '显示信息。 List1.Clear '清除列表框。

End Sub 我有点不懂 List1.RemoveItem I '每隔一项 为什么是每隔一项? 为什么不是剩下51--100?

2004-05-07 16:24
firechun
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2004-4-13
收藏
得分:0 

ListBox的ListIndex是从零开始的。添加到ListBox中的Item的ListIndex分别是entry1=0,entry2=1......entry100=99 (等号后面是Item对应的ListIndex)

For I = 1 To 50 '确定如何 List1.RemoveItem I '每隔一项 Next I '删除。

当I=1时,entry2被删除,Listbox自动重新生成ListIndex,entry3=2,entry4=3.....当I=2时,entry3被删除,entry4=2,entry5=3......所以结果是每隔一项被删除了。

[此贴子已经被作者于2004-05-08 16:43:56编辑过]


本人在编程中国发表的所有文章,除特别说明外均属原创,转载时请注明作者编程中国
2004-05-07 19:06
一叶秋
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2004-4-21
收藏
得分:0 

1.2.3.4.5.6.7.8.9.10~~ 原来

1.3.4.5.6.7.8.9.10~~~当等1时,这时自动生成listindex,此时4的listindex为2

1.3.5.6.7.8.9.10~~~当等2时~~

谢谢!

2004-05-07 20:43
快速回复:小问题3
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016519 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved