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

K

kahunaVA

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
 
D

Douglas J. Steele

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
 
K

kahunaVA

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top