Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Input not reading a the whole line

Status
Not open for further replies.

OceanDesigner

Programmer
Oct 30, 2003
173
US
I am using Line Input to read lines out of a file. On loop 1, the code is reading the first line and printing to another file correctly. On loop two, Line Input is not reading the second line. It doesn't print anything (visible) into the output file. This does not happens on every line. For instance, it takes 7 loops to copy 5 lines to the second file. I do not have access the code that writes the input file. I am thinking there is some kind of code at the end of some of these lines that interrupts Line Input from reading the to the end of line. I need to make sure I am accouting for the number of lines that are being read.

Attached is the first 7 lines of the input file

-Jeff
 
I guess I need to know how to upload a file.

The first 7 lines are:

* Missile Datcom input file written by MissileLab
* Date and Time Written: 8/22/2008 2:16:29 PM
* based on CAD model
CASEID 1
BUILD
DAMP
DIM IN
 
My first guess might be NUL characters in there. While in most places VB will handle them fine, there are places where API calls are made that treat a NUL as "end of string" and truncate the rest.

You need a simple hex file viewer.
 
I downloaded a hex viewer. I am vaguely familiar with hex, so I don't know how to tell if there is a NUL. I don't know what I am looking for, but I didn't see anything that looked like a NUL. What am I looking for?

Suppose there is a NUL, is there some way to hadle it - either account for it or blow right past it.
 
Yes, look for any 00 characters in your hex viewer program.

Offhand I can't think of anything else in there to cause line truncation using Line Input#.

You can't upload a file here. The idea is if you have the file on some web server you can add a link to it in here.
 
Well Line Input# is supposed to treat either LF or CRLF as a line delimiter, and read everything else. So I doubt that reading itself is the problem with or without any &H00's in the file.

Have you tried a Debug.Print of each line of text and maybe also the line's Len() for each line read? Do this as two separate statements:
Code:
Line Input# intFileNum, strLine
Debug.Print strLine
Debug.Print Len(strLine)
That might reveal something.
 
Oops! I meant to say a line-end is either CR or CRLF.

Just a LF is not documented as a valid line-end by itself.
 
Thanks for your help. I made a stupid mistake. I was incrementing my variable "linecount" inside my "For linecount = 1 To 7". The problem had nothing to do with Line Input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top