VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Color,Bolden,etc any word's of your choice in a RichTextBox

by Lee Hayler (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 23rd January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Color,Bolden,etc any word's of your choice in a RichTextBox

Rate Color,Bolden,etc any word's of your choice in a RichTextBox



Public Function ColorWord(RTF As RichTextBox, Swords As String, Scolor As ColorConstants, _
SFontsize As Integer, Sbold As Boolean, Sitalic As Boolean, Sbullet As Boolean)
search = 1
Do Until search = 0
search = InStr(search, RTF.Text, Swords, vbTextCompare)
If search > 0 Then
With RTF
          .SelStart = search - 1
          .SelLength = Len(Swords)
          .SelColor = Scolor
          .SelFontSize = SFontsize
          .SelBold = Sbold
          .SelItalic = Sitalic
          .SelBullet = Sbullet
End With
search = search + Len(Swords)
End If
Loop
With RTF
          .SelStart = Len(RTF.Text)
          .SelColor = vbBlack
          .SelFontSize = 8
          .SelBold = False
          .SelItalic = False
          .SelBullet = False
End With
End Function

'********CALL THE FUNCTION FROM YOUR FORM LIKE THIS********

ColorWord rtb, "blue", vbBlue, 10, True, False, False

***********************************************************

Download this snippet    Add to My Saved Code

Color,Bolden,etc any word's of your choice in a RichTextBox Comments

No comments have been posted about Color,Bolden,etc any word's of your choice in a RichTextBox. Why not be the first to post a comment about Color,Bolden,etc any word's of your choice in a RichTextBox.

Post your comment

Subject:
Message:
0/1000 characters