VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



I have a text box that I need to print directly from VB. Problem is there is no Word Wrap functio

by Chris Uttenweiler (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 5th November 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

I have a text box that I need to print directly from VB. Problem is there is no "Word Wrap" functionality. Other posts and Knowledge Base

Rate I have a text box that I need to print directly from VB. Problem is there is no Word Wrap functio



'TempMsg is the string that I build the printable message
'SelStart is the SelStart property of the text box - assigning it directly did not work
'75 is the number of characters that I needed on a line.

Dim TempMsg As String
    Dim SelectLength, SelectStart, Trapper As Integer
    If Len(Me.txtMsg.Text) < 75 Then
        TempMsg = Me.txtMsg.Text
    Else
        SelectStart = 0
        SelectLength = 75
        Do While Len(Me.txtMsg.Text) > 0
            Clipboard.Clear
            If Len(Me.txtMsg.Text) < 75 Then
                Me.txtMsg.SelLength = Len(Me.txtMsg.Text)
            Else
                Me.txtMsg.SelLength = 75
            End If
            
            Trapper = InStrRev(Me.txtMsg.SelText, Chr(32), -1, vbBinaryCompare)
            If Trapper = 0 Then
                 Me.txtMsg.SelLength = Len(Me.txtMsg.Text)
            Else
                 Me.txtMsg.SelLength = Trapper
            End If
                
            TempMsg = TempMsg & Me.txtMsg.SelText & Chr(13)
            MsgBox TempMsg
            Me.txtMsg.SelText = ""
            Me.txtMsg.SelStart = 0
        Loop
    End If

Download this snippet    Add to My Saved Code

I have a text box that I need to print directly from VB. Problem is there is no Word Wrap functio Comments

No comments have been posted about I have a text box that I need to print directly from VB. Problem is there is no Word Wrap functio. Why not be the first to post a comment about I have a text box that I need to print directly from VB. Problem is there is no Word Wrap functio.

Post your comment

Subject:
Message:
0/1000 characters