VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Print text from a multi-line text box to a printer with line-wrap. If you need to print the content

by Ben Jimenez (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 24th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Print text from a multi-line text box to a printer with line-wrap. If you need to print the contents of a text box to the printer, but are not

API Declarations


Public newL As String

Rate Print text from a multi-line text box to a printer with line-wrap. If you need to print the content



'This sub will take the text of entry and create the new value of newL which
'will include line breaks. You can adjust the length of the line break by 
'increasing or decreasing the MaxChar value. This was modified from the original
'version that was posted on lbnews groups as wrap1.zip on Yahoo

Dim ist As Integer
Dim MaxChar As Integer
Dim CrLf As String
Dim oldL As String
Dim lne As String
Dim nst As Integer

        CrLf = Chr(13) + Chr(10)
        MaxChar = 70 
        oldL = entry
        newL = ""

    ist = 1
    While ist < Len(oldL)
        nst = InStr(ist, oldL, CrLf)
        If nst = 0 Then
            lne = Mid(oldL, ist)
            ist = Len(oldL)
        Else
            lne = Mid(oldL, ist, nst - ist)
            ist = nst + 2
            If lne = "" Then newL = newL + CrLf
            End If
        While lne <> ""
            If Len(lne) <= MaxChar Then
                newL = newL + lne + CrLf
                lne = ""
              Else
                If InStr(lne, " ") < 1 Then
                    newL = newL + Left(lne, MaxChar) + CrLf
                    lne = Mid(lne, MaxChar + 1)
                  Else
                    Char$ = ""
                    Index = MaxChar + 1
                    While Char <> " "
                        Char = Mid(lne, Index, 1)
                        Index = Index - 1
                    Wend
                    newL = newL + Left(lne, Index + 1) + CrLf
                    lne = Mid(lne, Index + 2)
                End If
            End If
        Wend
    Wend
End Sub

Download this snippet    Add to My Saved Code

Print text from a multi-line text box to a printer with line-wrap. If you need to print the content Comments

No comments have been posted about Print text from a multi-line text box to a printer with line-wrap. If you need to print the content. Why not be the first to post a comment about Print text from a multi-line text box to a printer with line-wrap. If you need to print the content.

Post your comment

Subject:
Message:
0/1000 characters