我的c:\\下有兩個檔案分別是t1.txtt2.txt我想要把兩個檔案相同的列作刪除請問要如何作呢?例如:t1.txt的第五列是"ABC DEF"而t2.txt的第八列也是"ABC DEF"那就把t1.txt的第五列及t2.txt的第八列作刪除麻煩了,謝謝
2006-11-09 14:21:29 · 1 個解答 · 發問者 橘子 5 in 電腦與網際網路 ➔ 程式設計
W.J.S兄台你好
只要刪t2.txt的第8列即可
麻煩了,謝謝
2006-11-09 18:05:57 · update #1
如果t1.txt的第五列是"ABC DEF"
t2.txt的第8列跟第10列都是"ABC DEF"
這樣t2.txt是2列都刪還是只刪第8列或第10列?
2006-11-10 02:01:01 補充:
'我的做法是以較少的一方為刪除的依據,如t1有2個a,t2有3個a,執行後t1沒有a,t2剩1個a,有問題的話再提出.Private Sub Command1_Click() Dim A$(), B$(), S$, I&, J& I = FreeFile Open "C:\t1.txt" For Input As #I Do Until EOF(I) Line Input #I, S ReDim Preserve A(J): A(J) = S: J = J + 1 Loop J = 0 I = FreeFile Open "C:\t2.txt" For Input As #I Do Until EOF(I) Line Input #I, S ReDim Preserve B(J): B(J) = S: J = J + 1 Loop Close For I = 0 To UBound(A) For J = 0 To UBound(B) If A(I) = B(J) Then A(I) = Chr(0): B(J) = Chr(0): Exit For End If Next Next A = Filter(A, Chr(0), False) B = Filter(B, Chr(0), False) I = FreeFile Open "C:\t1.txt" For Output As #I Print #I, Join(A, vbCrLf) I = FreeFile Open "C:\t2.txt" For Output As #I Print #I, Join(B, vbCrLf) CloseEnd Sub
2006-11-09 21:01:01 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋