Question Inserting a pagebreak

Joined
Nov 9, 2009
Messages
16
Programming Experience
Beginner
Greetings

I'm relatively new to Visual Basic I’ve been looking for a solution to this for two days. I have a report that I need to print out in landscape. That part isn’t a problem. I need to read the text in the line that’s read by the reader and see if the substring is “Page#”. I can do that but when the reader reads the next line it appends it to the first line. The means that the substring will always say “Page#”. I need to read the text “Page#” place 45 more lines of text and then force a new page. Then start the hole thing over again with the next page.

Here is my code:

Using objReader As New IO.StreamReader("C:\Temp\GeoRptTemp.txt", False)
Do While objReader.Peek() <> -1
i = i + 1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
If TextLine.Length > 106 Then
strPage = TextLine.Substring(100, 6)
If strPage = "Page#" Then
strPage = ""
ElseIf i = 45 Then
TextLine = vbCrLf
End If
End If
RichTextBoxPrintCtrl1.Font = New Font("Lucida Console", 10, FontStyle.Regular)
RichTextBoxPrintCtrl1.Text = TextLine
Loop
End Using
Attached is a sample of the report.

Any help would be appreciated
 

Attachments

  • GR0134_clearing.txt
    20.8 KB · Views: 12
I've gotten a little futher. I've been able to read just a single line and put in to an array:

Dim sLine As String = ""
Dim arrText As New ArrayList()
Dim i As Integer

Dim objReader As New StreamReader("C:\Temp\GeoRptTemp.txt")
Do
i += 1
sLine = objReader.ReadLine
If Not sLine Is Nothing Then
Call SubString(sLine, i)
If i = 45 Then
sLine = (vbCrLf)
End If
arrText.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()

Sub SubString(ByVal sline As String, ByVal i As Integer)
Dim strSubString As String

If sline.Length > 106 Then
strSubString = sline.Substring(100, 6)
If strSubString = ("Page# ") Then
i = 0
End If
End If

End Sub

I'm not sure how to get it from the array into my RichTextBox so I can test it.
 
Back
Top