Private Type rec
no As Integer
name As String
num1 As Single
num2 As Single
End Type
Private Sub Command1_Click()
Dim s() As rec
ReDim s(0) As rec
total = 0
fn = FreeFile
Open "d:\data.txt" For Input As fn
Do While Not EOF(fn)
Line Input #fn, stri
'由于文件中的数据不够规范,有TAB有空格,
'下面几条语句,把最前面的空格删除,各数据之间只用一个空格分开
stri = Replace(stri, vbTab, " ")
Do While InStr(stri, " ") <> 0
stri = Replace(stri, " ", " ")
Loop
If Left(stri, 1) = " " Then stri = Mid(stri, 2)
'读出的数据保存到数组s中,记录条数记录在total中
a = Split(stri, " ")
total = total + 1
ReDim Preserve s(total) As rec
s(total).no = a(0)
s(total).name = a(1)
s(total).num1 = a(2)
s(total).num2 = a(3)
Loop
Close fn
fn = FreeFile
Open "d:\output.txt" For Output As fn
'看不明白你想要输出什么内容,在此只输出AJ04的信息
'要输出什么其它信息,请自己从结构数组s中提取
For i = 1 To total
If s(i).name = "AJ04" Then
Print #fn, s(i).no & vbTab & s(i).name & vbTab & s(i).num1 & vbTab & s(i).num2
End If
Next i
Close fn
End Sub