我做了一个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,我实在是想不出了,请高手指教!
可以输入如下形式的数据(注意是这样的形式,数据可以是随便)
(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,我实在是想不出了,请高手指教!
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