注册 登录
编程论坛 VB6论坛

求助,请问如何检索以,分隔的重复项?

狂笨的孔明 发布于 2019-06-17 14:13, 1990 次点击
请问如何检索以,分隔的相同项?
比如:人参不能与藜芦同服,能检索出A1与B2同时存在。
      A        B
1    人参    ,藜芦,
2    藜芦    ,人参,细辛,辛勺,


谢谢
4 回复
#2
wufuzhang2019-06-17 14:55
回复 楼主 狂笨的孔明
Option Explicit

Private Sub Command1_Click()
  Dim str As String
  Dim A
  Dim i As Integer
  Dim RenSenFlag As Boolean
  Dim LiLuFlag As Boolean

  
  str = "藜芦,人参,细辛,辛勺,"
  A = Split(str, ",")
  For i = 0 To UBound(A)
      If A(i) = "人参" Then RenSenFlag = True: Exit For
  Next
  For i = 0 To UBound(A)
      If A(i) = "藜芦" Then LiLuFlag = True: Exit For
  Next
  If RenSenFlag And LiLuFlag Then
     MsgBox "str中同时含有人参和藜芦", vbCritical + vbOKOnly, "警告"
  End If
End Sub
#3
狂笨的孔明2019-06-18 12:43
回复 2楼 wufuzhang
感谢,我去试试
#4
狂笨的孔明2019-06-18 13:09
回复 2楼 wufuzhang
您好,请问我的str有很多行,而且内容不固定,可以做到随时更新吗?
#5
wufuzhang2019-06-18 13:19
回复 4楼 狂笨的孔明
行数你应该清楚吧,用一个For循环,每次替换str的内容就可以了。
1