192.168.58.60:135
192.168.58.50:135
192.168.58.40:135
192.168.58.30:135
192.168.58.20:135
192.168.58.10:135
text2填文本2的路徑,就是妳下面說的那個txt,再拉壹個按鈕,加入以下代碼:
Private Sub Command1_Click()
On Error GoTo Error_Handler
Dim isOpen1, isOpen2 As Boolean
Open Text1.Text For Input As #1
isOpen1 = True
Dim all$
all = Input(LOF(1), 1)
MsgBox all '讀入
Dim oRegExp As New RegExp
oRegExp.Pattern = _
"((?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])\." & _
"(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])):\d+"
oRegExp.Global = True
all = oRegExp.Replace(all, "$1") '替換
MsgBox all '結果
Open Text2.Text For Input As #2
isOpen2 = True
all = Input(LOF(2), 2)
MsgBox all '讀入
Dim x As MatchCollection
oRegExp.Pattern = _
"((?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])\." & _
"(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.(?:[01]?\d\d?|2[0-4]\d|25[0-5]) \d+) (?=Open)"
Set x = oRegExp.Execute(all) '匹配
all = ""
For Each Item In x
all = all & Item & vbCrLf
Next
MsgBox all '結果
Error_Handler:
If isOpen1 Then Close #1
If isOpen2 Then Close #2
If Err Then Err.Raise Err.Number, , Err.Description
End Sub