Sub ReadDataFile()
Const DATAFILE = "d:\toto.txt"
Dim strLine As String
Dim strField As String
Dim varValue As Variant
Open DATAFILE For Input As #1
varValue = Null
Do Until EOF(1)
Line Input #1, strLine
Select Case Trim(strLine)
Case "NOMENCLATURE", "STOCK NUMBER", "PART NUMBER", "CAGE", _
"UNIT OF ISSUE", "UNIT OF MEASUREMENT CODE", _
"UNIT OF MEASUREMENT QUANTITY", "QUANTITY REQUIRED"
If Not IsNull(varValue) Then
MsgBox "Processing: " & strField & vbCrLf & varValue
varValue = Null
End If
strField = strLine
Case Else
If strLine Like "DESCRIPTION :*" Then
If Not IsNull(varValue) Then
MsgBox "Processing: " & strField & vbCrLf & varValue
varValue = Null
End If
strField = "DESCRIPTION"
varValue = Trim(Mid(strLine, 14))
Else
varValue = varValue + vbCrLf & strLine
End If
End Select
Loop
If Not IsNull(varValue) Then
MsgBox "Processing: " & strField & vbCrLf & varValue
varValue = Null
End If
Close #1
End Sub
|