Results 1 to 6 of 6

Thread: How do I use Rich Text Box's?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Cool

    Okay, how do I choose sertain text to change color, or to bold or italics?

    And also, someone gave me code a while ago to put pictures into richtextboxs but I lost the code, can someone give it to me again. Thanks guys.

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You can modify selected text like:
    Code:
    Text1.SelColor = 255
    Text1.SelBold = 1
    ...
    Or you can add ie. red text like this:
    Code:
    Text1.SelColor = 255
    Text1.SelText = "Red Test"
    Text1.SelColor = RGB(0, 0, 255)
    Text1.SelText = "Blue Test"
    Everything clear?

  3. #3
    Guest
    To Put Picture's in a RichTextBox, you can just copy the picture, and Paste it in. (To get the Edit menu to appear when you Right-Click, set the AutoVerbMenu property to True.

    Use the SelBold, SelItalic, SelUnderline and SelStrikeThru properties to change the Selected text to any of the 4 styles.
    Code:
    RichTextBox1.SelBold = Not RichTextBox1.SelBold
    RichTextBox1.SelItalic = Not RichTextBox1.SelItalic
    RichTextBox1.SelUnderline = Not RichTextBox1.SelUnderline
    RichTextBox1.SelStrikeThru = Not RichTextBox1.SelStrikeThru
    Use SelColor to change to a different Colour.
    Code:
    'Changes to Blue colour
    RichTextBox1.SelColor = vbBlue

  4. #4
    Guest
    Or you can change a certain portion of the text a different color and leave the rest black or any other color.

    Code:
    Private Sub Form_Load ()
     With RichTextBox1
         .Text = "Welcome to the RichTextBox Sample Source Code!"
         .SelStart = 0
         .SelLength = Len(.Text)
         .SelFontName = "Arial"
         .SelFontSize = 10
         .SelAlignment = rtfCenter
         .SelStart = InStr(.Text, "RichTextBox") - 1
         .SelLength = Len("RichTextBox")
         .SelFontName = "Courier New"
         .SelColor = vbBlue
         .SelStart = InStr(.Text, "Sample Source Code") - 1
         .SelLength = 4
         .SelFontName = "Courier New"
         .SelUnderline = True
         .SelStart = .SelStart + 1
         .SelLength = 1
         .SelColor = vbRed
         .SelStart = .SelStart + 1
         .SelLength = 1
         .SelColor = vbBlue
         .SelStart = .SelStart + 1
         .SelLength = 1
         .SelColor = vbGreen
         .SelStart = 0
         .SelLength = 0
      End With
    End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Thanks guys. Just what I was looking for

  6. #6
    New Member
    Join Date
    May 1999
    Location
    Boise, Idaho, USA
    Posts
    3
    What about subscript and superscript?

    Thanks,
    Roger
    Roger Eagans
    Senior Technician/Programmer

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