vb 读两个文件,生成另一个文件
发布网友
发布时间:2023-10-19 14:29
我来回答
共2个回答
热心网友
时间:2024-12-04 13:53
a,b放到C盘
c文件也将生成到C盘
Private Sub Command1_Click()
Dim a() As String, b() As String
Dim t1, t2 As String, j As Integer
t2 = ""
Open "c:\a.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, t1
t2 = t2 & t1 & ","
Loop
a = Split(t2, ",")
t2 = ""
Open "c:\b.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, t1
t2 = t2 & t1 & ","
Loop
b = Split(t2, ",")
Close 1, 2
t2 = ""
t1 = ""
j = 1
For i = 0 To UBound(a)
If a(i) = b(j) Then t2 = t2 & t1 & a(i) & vbCrLf: t1 = "": j = j + 1
t1 = t1 & a(i) & ","
Next i
Open "c:\c.txt" For Output As #3
Print #3, t2
Close 3
End Sub
热心网友
时间:2024-12-04 13:53
建议去看书,这个程序很容易实现
百度Google均可