回复 3楼 风吹过b
谢谢版主,我一直试过好多办法都没搞定!格式是固定的,但行数是变动的
Private Sub Command1_Click() Dim StartLog As Boolean Dim Arr, i% StartLog = False Open "C:\M49855360174X.txt" For Input As #1 ReDim Arr(1 To 1000, 1 To 4) Do While Not EOF(1) Line Input #1, a If StartLog = True And InStr(a, "Jabil Circuit Pull List Report") > 0 Then Exit Do If InStr(a, "Individual Ref.no:") > 0 Then i = i + 1 Arr(i, 1) = Trim$(Mid(a, 19, 15)) Arr(i, 2) = Mid(Split(a, ":")(1), 11, 4) End If If InStr(a, "Storage location for replenishment:") > 0 Then Arr(i, 4) = Split(a, ":")(1) If InStr(a, "Cost Center:") > 0 Then Arr(i, 3) = Split(a, ":")(1) If InStr(a, "Avail Stock") > 0 Then StartLog = True: GoTo NextLine If StartLog Then If InStr(a, "------------") > 0 Then GoTo NextLine Else If InStr(1, Mid(a, 1, 18), " ") = 0 Then i = i + 1 Arr(i, 1) = Mid(a, 1, 18) Else Arr(i, 2) = Arr(i, 2) + CLng(Trim$(Mid(a, 57, 19))) Arr(i, 3) = CLng(Trim$(Mid(a, 77, 8))) Arr(i, 4) = Trim$(Mid(a, 99, 6)) End If End If End If NextLine: Loop Close #1 Erase Arr End Sub