Results 1 to 2 of 2

Thread: [RESOLVED] [02/03] ReadLine doesn't seem to find all text when adding to listbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005

    Resolved [RESOLVED] [02/03] ReadLine doesn't seem to find all text when adding to listbox

    Hey, does anyone know why, when I read from a batch file that contains numerous lines and then add the lines to a list box, some of the lines get cut off or added incorrectly?
    This typically happens after about the 10th or 11th line is added to the listbox. Here is the code:

    [FONT=Trebuchet MS]Do While srReader.Peek() >= 0
    strSecondaryPrinter = srReader.ReadLine.Replace(ControlChars.Quote, "")
    If strSecondaryPrinter.StartsWith("NET USE LPT") Then
    lstAddPrinters.ForeColor = ForeColor.Red()
    strSecondaryPrinter = strSecondaryPrinter.Remove(14, 21)
    strSecondaryPrinter = strSecondaryPrinter.Remove(0, 35)
    End If
    lstAddPrinters.Items.Add(strSecondaryPrinter) '.ToString())
    srReader.BaseStream.Seek(1, SeekOrigin.Current)

    It still reads through the entire file, but the 'bad' line is either too short or runs into the next line.
    If there are less than 10 lines, there is never a problem - any help would be appreciated..
    Is this some sort of buffer issue?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: [02/03] ReadLine doesn't seem to find all text when adding to listbox

    Have you stepped through your code to see exactly what is being assigned at each point? Place a breakpoint at the top of the code and step through it using F10. You can use the Locals window to follow the value of strSecondaryPrinter at each step. You first need to confirm that incorrect data is being returned by ReadLine. I'm guessing that it's your code that is corrupting the data, so you need to use the debugger to diagnose the problem.

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