我做了一个text文本筐,还做了个button的按纽,现在在文本筐中 
可以输入如下形式的数据(注意是这样的形式,数据可以是随便) 
      (a) 1-20,3,4,60 
      (b)3,4,1-50,4,7 
从(a)可以发现,其实1-20已经包含了3,4,所以我想通过点button按纽后 
变成(a) 1-20,60,也是说通过button来修改用户的有时候的误输入 
同样道理正确的(b)应该是:1-50,我实在是想不出了,请高手指教! 

解决方案 »

  1.   

    首先用split分离出单独的数据然后查找到 带有 - 的数据,分离出最小值和最大值,然后挨个检测数据,在范围内的去掉,不在的保留,合并成带,分隔的数据,输出
      

  2.   

    如果类似 1-20 的只有一项:
    Private Sub Command1_Click()
    Dim strItem() As String
    Dim strLimit() As String
    Dim i As Integer, n As IntegerstrItem = Split(Text1, ",")
    For i = 0 To UBound(strItem)
        If InStr(strItem(i), "-") Then
            n = i
            Exit For
        End If
    Next istrLimit = Split(strItem(n), "-")Text1 = ""
    For i = 0 To UBound(strItem)
        If i = n Then
            If i > 0 And Text1 > "" Then Text1 = Text1 & ","
            Text1 = Text1 & strItem(i)
        Else
            If Val(strItem(i)) < Val(strLimit(0)) Or Val(strItem(i)) > Val(strLimit(1)) Then
                If i > 0 And Text1 > "" Then Text1 = Text1 & ","
                Text1 = Text1 & strItem(i)
            End If
        End If
    Next i
    End Sub
      

  3.   

    楼上的,应该是text1.text吧?!