比如list1里有:XX625X37X5X725
               X332XX123XXX13
               23432XX234XXX1
               234X23XX23XX34
                …………
                …………这4列数,我想把一组数里不是5个X的删掉,留下数组有5个X的数,比如上面我要把第2、3组数字删掉,留下1、4组,并把1、4组的数放到list2里面。

解决方案 »

  1.   

    加到LIST2的你自己写没问题,删除么就判断len(list1.item(I).text)-len(replace(list1.item(I).text,"x"))是否不等于5,是就删除。
      

  2.   

    这个吗?
    Function Bol(ByVal mChar As String) As Boolean
        Dim i As Integer, n As Integer
        n = Len(mChar) - Len(Replace(mChar, "X", ""))
        If n = 5 Then
            Bol = True
        Else
            Bol = False
        End If
    End FunctionPrivate Sub Command1_Click()
        Dim i As Integer
        Dim b As Boolean
        Dim s As String
        For i = 0 To List1.ListCount - 1
            s = List1.List(i)
            If Bol(s) Then
                List1.RemoveItem (i)
                List2.AddItem s
            End If
        Next i
    End SubPrivate Sub Form_Load()
        List1.AddItem "XX625X37X5X725"
        List1.AddItem "X332XX123XXX13"
        List1.AddItem "23432XX234XXX1"
        List1.AddItem "234X23XX23XX34"
    End Sub
      

  3.   

    恩。3楼的没问题。
    问2楼:
    (list1.item(I).text)-len(replace(list1.item(I).text,"x"))
    "item"VB中我怎么找不到`!
      

  4.   

    UP------------------------------------------------
    有尝聘用版主:) 有兴趣的来看看
    www.dvpx.com 论坛首页公告MSN:[email protected]
      

  5.   

    LIST写成ITEM啦,倒是三楼的其实会出错,和里面的序列次序有关。