Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the problem hope someone helps. I am not using a database because it is not required. So from excelsheet I have to copy the records and paste it to the textbox in my vb form (multiline). Example I have 30 lines
1. Happy
2. Sad
3. Angry
4. and so on.....
Now in my reportviewer I have to view only 10 lines per page but I did not use dataset as said I don't need a database. What I did is I used textbox too and pass the data from vb form to report using parameters.

Question? How can I display or divide the textbox content for 10 items / line per page. So if I have 30 items / lines that should give me 3 pages in total.

Thanks in advance.

What I have tried:

Never tried anything cant find any answers.
Posted
Updated 27-Oct-19 0:32am

1 solution

Something like this:
Public Class Form1
    Dim countLines As Int32
    Dim array(10) As String

    Sub PrintLines()
        countLines = 0

        ' Loop over lines in TextBox.
        For Each line As String In TextBox1.Text.Split(vbCrLf)
            array(countLines) = line.Replace(vbLf, "")
            countLines = countLines + 1

            If countLines = 10 Then
                countLines = 0
                ' Your print page routine here

                System.Array.Clear(array, 0, 10)
            End If
        Next

        If countLines > 0 Then
            Console.WriteLine("Printing the last page ...")
            ' Your print page routine here
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ' Create some test lines
        For index = 1 To 35
            TextBox1.Text = TextBox1.Text + "test " + index.ToString + vbCrLf
        Next

        PrintLines()
    End Sub
End Class
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900