title: Hasmorepages property fails
body: <p>I have created a routine that is intended to print a variable number of lines and/or pages, based on a queue of line information previously stored.  Each page prints fine, but when printing more than one page, two pages overprint.  I can't see my logic error, but there must be one.  A copy of the offending code is follows.  Nextline.newpage is a boolean set to true to force a new page.  In my text example there were six "Newpage" and "hasmorepages" was set to true six times, and the routine was exited six times.  Still the output was four pages with one printing correctly, and three with two pages printed on one sheet.  Any help would be greatly appreciated.  By the way, this is my first question, so be kind.</p>
  
  <pre><code>Private Sub PrintLines(Sender As Object, e As PrintPageEventArgs) Handles PrintDoc.PrintPage
      Dim White As String = GetARGBString(PrinterDefaultBackcolor)
      Do Until Lines.Count = 0
          Dim Nextline As Lineformat = Lines.Dequeue
          If Nextline.NewPage Then
              e.HasMorePages = True
              Exit Sub
          End If
          With Nextline
              Dim LineBackColor As String = Nextline.backColor
              If LineBackColor &lt;&gt; White Or .Borders = True Then DrawShape(Nextline, e)
              If .Text &lt;&gt; "" Then DrawText(Nextline, e)
          End With
      Loop
  
  End Sub
  
  Private Sub DrawShape(Line As Lineformat, E As PrintPageEventArgs)
      With Line
          Dim Top As Integer = .Top * 100
          Dim Left As Integer = .Left * 100
          Dim Width As Integer = .BackGroundWidth * 100
          Dim Height As Integer = .BackGroundHeight * 100
          Dim Point As New Point(Left, Top)
          Dim Size As New Size(Width, Height)
          Dim Rect As New Rectangle(Point, Size)
          Dim TransparentFillColor As String = "00" &amp; Strings.Right(.backColor, 6)
          Dim FillColor As FullColor = GetColorFromString(.backColor)
          Dim BorderPen As New Pen(Color.Black)
          Dim FillBrush As New SolidBrush(FillColor.Color)
          E.Graphics.FillRectangle(FillBrush, Rect)
          If Line.Borders = True Then
              E.Graphics.DrawRectangle(BorderPen, Rect)
          End If
      End With
  
  End Sub
  Private Sub DrawText(Line As Lineformat, E As PrintPageEventArgs)
  
      With Line
          Dim MyFont = SetFontStyle(.FontFamily, .FontPoints, .FontBold, .FontItalic, .FontUnderline)
          Dim TextColor As FullColor = GetColorFromString(.ForeColor)
          Dim MyBrush As New SolidBrush(TextColor.Color)
          Dim top As Integer = .Top * 100
          Dim Left As Integer = .Left * 100
          Dim Width As Integer = .LineWidth * 100
          Dim Height As Integer = .LineHeight * 100
          Dim point As New Point(Left, top)
          Dim Size As New Size(Width, Height)
          Dim Rect As New RectangleF(point, Size)
          Dim SF As New StringFormat()
          SF.FormatFlags = TextFormatFlags.WordEllipsis
          E.Graphics.DrawString(.Text, MyFont, MyBrush, Rect, SF)
      End With
  End Sub
  </code></pre>
  
  <p>End Class</p>