![]() |
#2
wmf20142019-07-10 09:33
|
我编写的程序如下:(问题:1、慢,想想要循环40000*28000次,10亿多次呢!怎么解决?
2、好象逻辑有错误,转出来的C文件与A文件完全一致,肯定应该不一致。)

Dim fn As Integer, str1 As String, str2 As String, tmp1, tmp2, i, j As Long
Dim a() As String
Dim b() As String
Dim cc As String
fn = FreeFile
Open "D:\A.txt" For Binary As #fn
str1 = Input(LOF(fn), fn)
tmp1 = Split(str1, vbCrLf, -1)
Close #fn
fn = FreeFile
Open "D:\B.txt" For Binary As #fn
str2 = Input(LOF(fn), fn)
tmp2 = Split(str2, vbCrLf, -1)
Close #fn
Open "D:\C.txt" For Append As #2
For i = LBound(tmp1) To UBound(tmp1) - 1
For j = LBound(tmp2) To UBound(tmp2) - 1
a = Split(tmp1(i), ",")
b = Split(tmp2(j), ",")
If a(0) = b(0) And a(1) = b(1) Then
cc = tmp2(j)
Else
cc = tmp1(i)
End If
Next j
If cc <> "" And aa <> "" Then
Print #2, cc
End If
Next i
Close #2
Dim a() As String
Dim b() As String
Dim cc As String
fn = FreeFile
Open "D:\A.txt" For Binary As #fn
str1 = Input(LOF(fn), fn)
tmp1 = Split(str1, vbCrLf, -1)
Close #fn
fn = FreeFile
Open "D:\B.txt" For Binary As #fn
str2 = Input(LOF(fn), fn)
tmp2 = Split(str2, vbCrLf, -1)
Close #fn
Open "D:\C.txt" For Append As #2
For i = LBound(tmp1) To UBound(tmp1) - 1
For j = LBound(tmp2) To UBound(tmp2) - 1
a = Split(tmp1(i), ",")
b = Split(tmp2(j), ",")
If a(0) = b(0) And a(1) = b(1) Then
cc = tmp2(j)
Else
cc = tmp1(i)
End If
Next j
If cc <> "" And aa <> "" Then
Print #2, cc
End If
Next i
Close #2
文件:
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
请版主和路过的坛友及高手不吝赐教,多谢多谢!