怎么将text1.text内指定的内容按下命令按钮后保留,删除不需要的内容
比如text1.text的内容是
1111 5 2222 3333 444 1111 5 2222........
1111 5 2222 3333 444 1111 5 2222........
1111 5 2222 3333 444 1111 5 2222........要保留1111 2222之间的内容(那个5)删除其他不需要的
比如text1.text的内容是
1111 5 2222 3333 444 1111 5 2222........
1111 5 2222 3333 444 1111 5 2222........
1111 5 2222 3333 444 1111 5 2222........要保留1111 2222之间的内容(那个5)删除其他不需要的
Dim i As Integer
Dim s As String
For i = 1 To 3
s = String(4, 48 + i)
Debug.Print s
Text1 = Replace(Text1, s, "")
Next
Text1 = Replace(Text1, 444, "")
Text1 = Replace(Text1, "........", "")
End Sub
那些444和只是个例子 又可能是8ncmdhfj 和515sadkkoh 等不规则的数 但是1111和2222是规则的数!!我是想保留下1111和2222之间的数!删除其他不规则的数!
Private Sub Command1_Click()
Dim str As String
Dim s1() As String
Dim s2() As String
Dim idx As Integer
Dim bln As Boolean
str = Text1
Do While InStr(str, Space(2)) > 0
str = Replace(str, Space(2), Space(1))
Loop
s1 = Split(str, Space(1))
ReDim s2(0)
For idx = 1 To UBound(s1) - 1
If s1(idx - 1) = "11111" And s1(idx + 1) = "22222" Then
If bln Then
ReDim Preserve s2(UBound(s2) + 1)
Else
bln = True
End If
s2(UBound(s2)) = s1(idx)
End If
Next
Text2 = Join(s2, Space(1))
End Sub
Private Sub Command1_Click()
Dim a$
ss = Split(Form1.Text1.Text, "1111 ")
For i = 0 To UBound(ss)
s = Split(ss(i), Space(1)): a = a & s(0)
Next i
Form1.Text2.Text = a
End Sub