注引用自allen_xxx(allen)http://www.csdn.net/expert/topic/292/292060.xml?temp=8.300418E-02Public SourcePgm As String Public MyArr As Variant Public MyDir As Variant Public Num As String Public Txt1 As String Public Txt2 As String Public Dir As String Public flags As Boolean Public Sub ChangeName(Source As String, Direct As String) '添加代码 End SubPrivate Sub Command1_Click() If MsgBox("这将是不可修复的,请确认!", vbOKCancel) Then MyDir = Split(MyArr(i), "\", -1, vbTextCompare) Dir = MyDir(0) For i1 = 1 To UBound(MyDir) - 1 Dir = Dir & "\" & MyDir(i1) Next i1
For i = 0 To Num - 1 Open MyArr(i) For Input Access Read As #1 MyDir = Split(MyArr(i), "\", -1, vbTextCompare) flags = False Do While Not EOF(1) ' 循环至文件尾。
Input #1, mystring ' 将数据读入变量。 If Len(mystring) >= 7 Then a = InStr(1, mystring, Txt1, vbTextCompare) If a >= 0 Then b = InStr(a, mystring, Txt2, vbTextCompare) If b >= 0 Then c = Mid(mystring, a + 7, b - a - 7) Form1.Caption = c Direct = c & ".htm"
flags = True Exit Do End If End If End If Label2.Caption = CInt(Label2.Caption) + 1 Loop Close #1
If flags = True Then ChangeName MyArr(i), Direct End If Next i
Else End If End SubPrivate Sub Form_Load() Txt1 = "<title>" Txt2 = "</title>" With CommonDialog1 '开文件问话框 .Filter = "html Files (*.html;*.htm)|*.html;*.htm" .FilterIndex = 3 .flags = &H200 .ShowOpen SourcePgm = .FileName End WithDim a As Variant MyArr = Split(SourcePgm, " ", -1, 1) Num = UBound(MyArr) + 1 Label1.Caption = "共选择了" & Num & "个文件" Form1.Caption = SourcePgm End Sub
历遍文件,改名
注引用自allen_xxx(allen)http://www.csdn.net/expert/topic/292/292060.xml?temp=8.300418E-02Public SourcePgm As String
Public MyArr As Variant
Public MyDir As Variant
Public Num As String
Public Txt1 As String
Public Txt2 As String
Public Dir As String
Public flags As Boolean
Public Sub ChangeName(Source As String, Direct As String)
'添加代码
End SubPrivate Sub Command1_Click()
If MsgBox("这将是不可修复的,请确认!", vbOKCancel) Then
MyDir = Split(MyArr(i), "\", -1, vbTextCompare)
Dir = MyDir(0)
For i1 = 1 To UBound(MyDir) - 1
Dir = Dir & "\" & MyDir(i1)
Next i1
For i = 0 To Num - 1
Open MyArr(i) For Input Access Read As #1
MyDir = Split(MyArr(i), "\", -1, vbTextCompare)
flags = False
Do While Not EOF(1) ' 循环至文件尾。
Input #1, mystring ' 将数据读入变量。
If Len(mystring) >= 7 Then
a = InStr(1, mystring, Txt1, vbTextCompare)
If a >= 0 Then
b = InStr(a, mystring, Txt2, vbTextCompare)
If b >= 0 Then
c = Mid(mystring, a + 7, b - a - 7)
Form1.Caption = c
Direct = c & ".htm"
flags = True
Exit Do
End If
End If
End If
Label2.Caption = CInt(Label2.Caption) + 1
Loop
Close #1
If flags = True Then
ChangeName MyArr(i), Direct
End If
Next i
Else
End If
End SubPrivate Sub Form_Load()
Txt1 = "<title>"
Txt2 = "</title>"
With CommonDialog1 '开文件问话框
.Filter = "html Files (*.html;*.htm)|*.html;*.htm"
.FilterIndex = 3
.flags = &H200
.ShowOpen
SourcePgm = .FileName
End WithDim a As Variant
MyArr = Split(SourcePgm, " ", -1, 1)
Num = UBound(MyArr) + 1
Label1.Caption = "共选择了" & Num & "个文件"
Form1.Caption = SourcePgm
End Sub