Nee way to get count of fields on current line of imported text fi

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is a bit of my code, I want to skip the current line if after the split
I can determine that it does not have the correct amount of fields. I think I
fixed the problem of the export query not putting it all on one line, but
want to be safe and make sure the code doesn't crash if that happens.

While Not EOF(1)
'Read a single line (dump the end of line marker)
Line Input #1, stTmp

'Split the readLine on Comma
Ary = Split(stTmp, ",")
'****If there is not ten fields, skip the record.****

Thanks for any help
 
While Not EOF(1)
'Read a single line (dump the end of line marker)
Line Input #1, stTmp

'Split the readLine on Comma
Ary = Split(stTmp, ",")
If UBound(Ary) = 9 Then
'There are 10 fields. Do what you need to
End If
 
Great, nice and simple
Thanks

Douglas J. Steele said:
While Not EOF(1)
'Read a single line (dump the end of line marker)
Line Input #1, stTmp

'Split the readLine on Comma
Ary = Split(stTmp, ",")
If UBound(Ary) = 9 Then
'There are 10 fields. Do what you need to
End If
 
Back
Top