vb如何删除list中的选项
先生成了一个list:ABCDABACADBCBDCDABCABDACDBCDABCD现在我要删除list中所有同时含有BC的选项,应如何实现...
先生成了一个list:A B C D AB AC AD BC BD CD ABC ABD ACD BCD ABCD
现在我要删除list中所有同时含有BC的选项,应如何实现 展开
现在我要删除list中所有同时含有BC的选项,应如何实现 展开
8个回答
展开全部
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), "BC") > 0 Then List1.RemoveItem i
Next
End Sub
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), "BC") > 0 Then List1.RemoveItem i
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private
Sub
Command1_Click()
List1.Clear
Dim
S()
S
=
Array("A",
"B",
"C",
"D",
"AB",
"AC",
"AD",
"BC",
"BD",
"CD",
"ABC",
"ABD",
"ACD",
"BCD",
"ABCD")
Dim
i
As
Integer
For
i
=
LBound(S)
To
UBound(S)
List1.AddItem
S(i)
Next
i
Label2.Caption
=
"当前有
"
&
List1.ListCount
&
"
条数据!"
End
Sub
Private
Sub
Command2_Click()
Dim
i
As
Integer
Label1.Caption
=
"下列值已被删除!"
For
i
=
List1.ListCount
-
1
To
0
Step
-1
If
InStr(List1.List(i),
"BC")
>
0
Then
Label1.Caption
=
Label1.Caption
&
vbCrLf
&
List1.List(i)
List1.RemoveItem
i
End
If
Next
i
Label2.Caption
=
"当前有
"
&
List1.ListCount
&
"
条数据!"
End
Sub
Sub
Command1_Click()
List1.Clear
Dim
S()
S
=
Array("A",
"B",
"C",
"D",
"AB",
"AC",
"AD",
"BC",
"BD",
"CD",
"ABC",
"ABD",
"ACD",
"BCD",
"ABCD")
Dim
i
As
Integer
For
i
=
LBound(S)
To
UBound(S)
List1.AddItem
S(i)
Next
i
Label2.Caption
=
"当前有
"
&
List1.ListCount
&
"
条数据!"
End
Sub
Private
Sub
Command2_Click()
Dim
i
As
Integer
Label1.Caption
=
"下列值已被删除!"
For
i
=
List1.ListCount
-
1
To
0
Step
-1
If
InStr(List1.List(i),
"BC")
>
0
Then
Label1.Caption
=
Label1.Caption
&
vbCrLf
&
List1.List(i)
List1.RemoveItem
i
End
If
Next
i
Label2.Caption
=
"当前有
"
&
List1.ListCount
&
"
条数据!"
End
Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for i= list1.listcount-1 to 0 step -1
if instr(list1.list(i),"BC")<>0 then
list1.remove(i)
endif
next
if instr(list1.list(i),"BC")<>0 then
list1.remove(i)
endif
next
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用do
while循环
只要list1里面有bc就不退出。自己控制循环变量i就可以了。
while循环
只要list1里面有bc就不退出。自己控制循环变量i就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
like也能实现。
Private
Sub
Command1_Click()
For
i
=
List1.ListCount
-
1
To
1
Step
-1
If
List1.List(i)
Like
"*BC*"
Then
List1.RemoveItem
i
Next
i
End
Sub
Private
Sub
Form_Load()
List1.AddItem
"A"
List1.AddItem
"B"
List1.AddItem
"C"
List1.AddItem
"D"
List1.AddItem
"AB"
List1.AddItem
"AC"
List1.AddItem
"AD"
List1.AddItem
"BC"
List1.AddItem
"BD"
List1.AddItem
"CD"
List1.AddItem
"ABC"
List1.AddItem
"ABD"
List1.AddItem
"ACD"
List1.AddItem
"BCD"
List1.AddItem
"ABCD"
End
Sub
Private
Sub
Command1_Click()
For
i
=
List1.ListCount
-
1
To
1
Step
-1
If
List1.List(i)
Like
"*BC*"
Then
List1.RemoveItem
i
Next
i
End
Sub
Private
Sub
Form_Load()
List1.AddItem
"A"
List1.AddItem
"B"
List1.AddItem
"C"
List1.AddItem
"D"
List1.AddItem
"AB"
List1.AddItem
"AC"
List1.AddItem
"AD"
List1.AddItem
"BC"
List1.AddItem
"BD"
List1.AddItem
"CD"
List1.AddItem
"ABC"
List1.AddItem
"ABD"
List1.AddItem
"ACD"
List1.AddItem
"BCD"
List1.AddItem
"ABCD"
End
Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询