Private Sub IC_Click()
Dim B As Byte
Dim index As Double
Dim fso As FileSystemObject '要先添加引用“Microsoft Scripting Runtime”
dlg.ShowOpen
Filename = dlg.Filename
If Len(Filename) = 0 Then Exit Sub
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
fso.CopyFile Filename, Filename & ".bak", True
If Err.Number = 70 Then Tip.Text = "文件备份失败..."
Err.Clear
On Error GoTo 0
SetAttr Filename, 0
Open Filename For Binary As #1
DoEvents
index = 1
Do Until EOF(1)
Get #1, index, B
If B = 67 Then
index = index + 1
Get #1, index, B
If B = 77 Then
index = index + 1
Get #1, index, B
If B = 71 Then
Put #1, index + 1, 10
End If
End If
Else
index = index + 1
End If
Loop
Close 1
Open Filename For Binary As #1
index = 1
Do Until EOF(1)
Get #1, index, B
If B = 68 Then
index = index + 1
Get #1, index, B
If B = 80 Then
index = index + 1
Get #1, index, B
If B = 66 Then
Put #1, index + 1, 10
End If
End If
Else
index = index + 1
End If
Loop
Close 1
Open Filename For Binary As #1
index = 1
Do Until EOF(1)
Get #1, index, B
If B = 71 Then
index = index + 1
Get #1, index, B
If B = 67 Then
Put #1, index + 1, 10
End If
Else
index = index + 1
End If
Loop
Close 1
DoEvents
End Sub