192.168.0.140
1
2
3
4
5
6
192.168.0.141
1
2
3
4
5
6
192.168.0.142
1
2
3
4
5
6
现在要找到相应的machine_ip然后替换以下的6行文本 我是想读一行替换一行 问题是不能写如ini
Private Sub Command1_Click()
'On Error Resume Next
Dim pos As Integer
machine_ip = "192.168.0.141"
xxx = "a,b,c,d,e,f"
bb = Split(xxx, ",")
Dim temp_pos As IntegerOpen "C:\aa.ini" For Input As #1
Dim textline As String, str
Do While Not EOF(1)
Line Input #1, textline
temp_pos = InStr(1, textline, machine_ip)
If temp_pos > 0 Then pos = temp_pos
If pos > 0 And num < 6 Then
textline = Replace(textline, textline, bb(num)) '怎么把这个textline替换一行文本呢 num = num + 1
End If
Debug.Print textline
Loop
Close #1
If pos = 0 Then
Open "c:\aa.ini" For Append As #1
Print #1, machine_ip
For x = 0 To UBound(bb)
Print #1, bb(x)
Next
Close #1
End IfEnd Sub
1
2
3
4
5
6
192.168.0.141
1
2
3
4
5
6
192.168.0.142
1
2
3
4
5
6
现在要找到相应的machine_ip然后替换以下的6行文本 我是想读一行替换一行 问题是不能写如ini
Private Sub Command1_Click()
'On Error Resume Next
Dim pos As Integer
machine_ip = "192.168.0.141"
xxx = "a,b,c,d,e,f"
bb = Split(xxx, ",")
Dim temp_pos As IntegerOpen "C:\aa.ini" For Input As #1
Dim textline As String, str
Do While Not EOF(1)
Line Input #1, textline
temp_pos = InStr(1, textline, machine_ip)
If temp_pos > 0 Then pos = temp_pos
If pos > 0 And num < 6 Then
textline = Replace(textline, textline, bb(num)) '怎么把这个textline替换一行文本呢 num = num + 1
End If
Debug.Print textline
Loop
Close #1
If pos = 0 Then
Open "c:\aa.ini" For Append As #1
Print #1, machine_ip
For x = 0 To UBound(bb)
Print #1, bb(x)
Next
Close #1
End IfEnd Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货