Results 1 to 40 of 162

Thread: RichTextBox Tricks and Tips

Hybrid View

  1. #1
    New Member
    Join Date
    Oct 2005
    Posts
    13

    Re: RichTextBox Tricks and Tips

    I don't get the following code perform correctly:

    vb Code:
    1. Private Sub text2ADDText(xText As RichTextBox, fontN As String, fontS As Integer, fontI As Boolean, fontU As Boolean, fontB As Boolean, txt As String)
    2.     Dim text2Len As Long
    3.        
    4.     text2Len = Len(xText.Text)
    5.     xText.Text = xText.Text & vbCr & vbLf & txt
    6.     xText.SelStart = text2Len + 2
    7.     xText.SelLength = Len(txt)
    8.     xText.SelBold = fontB
    9.     xText.SelUnderline = fontU
    10.     xText.SelFontName = fontN
    11.     xText.SelFontSize = fontS
    12.    
    13. End Sub

    It only produces the desired result in the last line added to the control invoking the sub.

    Could you help me ...


    El quijoteMx

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: RichTextBox Tricks and Tips

    Quote Originally Posted by quijotemx
    I don't get the following code perform correctly:
    Is this any better?
    Code:
    Private Sub AppendText(RTB As RichTextBox, _
                    fontN As String, _
                    fontS As Integer, _
                    fontI As Boolean, _
                    fontU As Boolean, _
                    fontB As Boolean, _
                    NewText As String, _
                    Optional TextColor As Long = vbBlack)
    
        With RTB
            .SelStart = Len(.Text)
            .SelColor = TextColor
            .SelBold = fontB
            .SelItalic = fontI
            .SelUnderline = fontU
            .SelFontName = fontN
            .SelFontSize = fontS
            .SelText = vbCrLf & NewText
        End With
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width