注册 登录
编程论坛 VB6论坛

求助 判断两个List内的数值是否有重复

clyfd 发布于 2022-12-15 19:32, 1015 次点击
只有本站会员才能查看附件,请 登录


请老师帮助解决,如何判断List2中的数据与List1中是否有重复,如果重复,弹出提示并显示重复值,如无重复,弹出提示:无重复
2 回复
#2
mrexcel2022-12-15 20:55
这个循环判断即可,如:
程序代码:
Private Sub Command1_Click()
Dim s As String, t As String, i&
s = ",,"
With List1
For i = 0 To .ListCount - 1
s = s & .List(i) & ",,"
Next
End With

With List2
For i = 0 To .ListCount - 1
If InStr(s, ",," & .List(i) & ",,") Then t = t & "," & .List(i)
Next
End With
t = IIf(Len(t) > 1, Mid(t, 2), "无重复")
MsgBox t
End Sub
#3
clyfd2022-12-15 21:35
回复 2楼 mrexcel
老师,您太棒了,谢谢您,完全符合我的想法,感谢
1