Results 1 to 3 of 3

Thread: SendMessage & EM_GETLINECOUNT

  1. #1

    Thread Starter
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    Question

    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
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



  2. #2
    Guest
    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.

  3. #3
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    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...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width