I have been writing a little bit of code, which reads a text file (.txt) and passes the content to a string variable, which is then used in an email, along with a few other things. The code which reads the file is here:
fileName=“c:\File3.txt”
fileNum=Freefile()
Open fileName For Input As fileNum
Length = Lof(fileNum)
BodyText=""
BodyText = Input(Length, fileNum)
Close fileNum
Now, I have been using the above code, but I have modified one of the lines above to read:
BodyText = Input(Length/2, fileNum)
because I keep getting “Input past end of file” error. However, if I used the Length/2 I get the text perfect every time.
However the user who this was written for came back and told me that in fact they only got half the text from the file. I tried my code on their text file and I got the same result. If I changed the code to just Length and not Length/2 it worked for that 1 file only, all other txt files errored the same as above.
So basically I’d like to know why all of the text files I’ve used worked only with length/2 but this one file (it’s just text, a few paragraphs) only works with length…
All of the files I tested have no special characters.