那位帮忙转换一下,或者说下她的原理,我自己重新用AU3写
VERSION 5.00
Begin VB.Form Form1
Caption = "合并器"
ClientHeight = 4140
ClientLeft = 120
ClientTop = 420
ClientWidth = 4170
LinkTopic = "Form1"
ScaleHeight = 4140
ScaleWidth = 4170
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text4
Height = 375
Left = 1560
TabIndex = 7
Text = "1"
Top = 3480
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "合并出现次数=X的项(X=0即为导出所有项)"
Height = 495
Left = 240
TabIndex = 5
Top = 2880
Width = 3495
End
Begin VB.TextBox Text3
Height = 270
Left = 120
TabIndex = 4
Top = 2520
Width = 3735
End
Begin VB.CommandButton Command1
Caption = "导入"
Height = 420
Left = 240
TabIndex = 2
Top = 720
Width = 3495
End
Begin VB.TextBox Text1
Height = 270
Left = 120
TabIndex = 1
Top = 360
Width = 3735
End
Begin VB.Label Label4
Height = 375
Left = 120
TabIndex = 8
Top = 1320
Width = 1455
End
Begin VB.Label Label3
Caption = "X="
Height = 255
Left = 1200
TabIndex = 6
Top = 3600
Width = 615
End
Begin VB.Label Label2
Caption = "输出目录"
Height = 375
Left = 120
TabIndex = 3
Top = 2160
Width = 975
End
Begin VB.Label Label1
Caption = "输入目录"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a(500000) As String
Dim t(500000) As Integer
Dim Fso As Object
Dim F, F3, F4
Dim s As Integer
Dim str, strm, tstr As String
Dim hm, cu As Integer
Private Sub Command1_Click()
s = 0
hm = 0
cu = 0
Set Fso = CreateObject("Scripting.FileSystemObject")
Set F = Fso.getfolder(Text1.Text)
Set F3 = F.Files
For Each F4 In F3
ext = Fso.GetExtensionName(F4.Path)
If ext = "txt" Then
Open F4.Path For Input As #1
While Not EOF(1)
Line Input #1, str
hm = hm + 1
Wend
Close #1
End If
Next
For Each F4 In F3
ext = Fso.GetExtensionName(F4.Path)
If ext = "txt" Then
Open F4.Path For Input As #1
While Not EOF(1)
Line Input #1, str
cu = cu + 1
Label4.Caption = CStr(cu) + "/" + CStr(hm)
DoEvents
tstr = ""
For i = 1 To Len(str)
strm = Mid(str, i, 1)
If strm <> "," Then tstr = tstr + strm
Next i
flag = 0
For i = 1 To s
If a(i) = tstr Then
flag = 1
t(i) = t(i) + 1
Exit For
End If
Next i
If flag = 0 Then
s = s + 1
t(s) = 1
a(s) = tstr
End If
Wend
Close #1
End If
Next
End Sub
Private Sub Command3_Click()
x = Val(Text4.Text)
If Right(Text3.Text, 1) = "\" Then Text3.Text = Left(Text3.Text, Len(Text3.Text) - 1)
Open Text3.Text + "\" + Text4.Text + ".txt" For Output As #1
For i = 1 To s
If x = 0 Then
Print #1, a(i)
ElseIf t(i) = x Then
Print #1, a(i)
End If
Next i
Close #1
MsgBox "已保存" + Text3.Text + "\" + Text4.Text + ".txt"
End Sub
Private Sub Form_Load()
Text1.Text = App.Path
Text3.Text = App.Path
End Sub
自己弄了一点,在被注释掉的那卡住了
#include <array.au3>
$Fso = ObjCreate("Scripting.FileSystemObject")
$F = $Fso.getfolder('I:\BBB\1')
$F3 = $F.Files
For $F4 In $F3
$ext = $Fso.GetExtensionName($F4.Path)
ConsoleWrite($F4.Path & @CRLF)
If $ext = "txt" Then
$file = FileRead ( $F4.Path )
;~ While Not $EOF(1)
;~ Line Input #1, str
;~ hm = hm + 1
;~ Wend
;~ Close #1
EndIf
Next
|