-
Why do I get a different result from these two operations?
Code:
Open sTxtFile For Input As iFile
frmMain.txtMandates.Text = Trim(Input(LOF(iFile), iFile))
Close #iFile
Open sTxtFile For Input As iFile
Do While Not EOF(iFile)
Line Input #iFile, sTemp
lCount = lCount + 1
Loop
Close #iFile
Gives 297 and is correct, but
Code:
lCount = SendMessage(ByVal frmMain.txtMandates.hwnd, EM_GETLINECOUNT, 0, 0)
Gives me 298.
I would prefer to use the API call on the text box to do this, but if this is inaccurate I can't.
Regards
-
The reason is probably because of an extra line.
Try testing it, load the file, see how many lines you have (298), than go to the end of the text file and erase the extra line. It should now be 297. That's just my $0.02.
-
There's probably a blank line at one end or other of the text file.
This was likely removed when you trimmed it as you imported it into the textbox.
If you figure it out, lets us know what the solution was please...