Click here to Skip to main content
14,364,319 members
Rate this:
Please Sign up or sign in to vote.
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 1:32am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   
v4

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100