vb如何删除list中的选项

来源:百度知道 编辑:UC知道 时间:2024/05/28 05:47:38
先生成了一个list:A B C D AB AC AD BC BD CD ABC ABD ACD BCD ABCD
现在我要删除list中所有同时含有BC的选项,应如何实现

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

实现的代码:
dim alldata() as string
dim aaa as integer
aaa = 0
for i = 0 to list1.listcount - 1
alldata(i) = list1.list(i)
next i

for i = 0 to ubound(alldata)
for j = 0 to list1.listcount - 1
if alldata(i) = list1.list(j) then aaa = aaa+1
next j
if aaa > =2 then list1.removeitem alldata(i)
next i

for i= list1.listcount-1 to 0 step -1
if instr(list1.list(i),"BC")<>0 then
list1.remove(i)
endif
next

remove