-
Nov 14th, 2005, 09:08 PM
#1
Thread Starter
Addicted Member
RichTextBox Find and Highlight Line with prefix
I have a richtextbox,
My format is something like this
*blahblahblah (newline)
so one line per asterisk code.
I want to expand this beyond other pieces of code as well.
Such as ((Text)) and highlight color the whole phrase, so far that's what I'm faced with now.
But I found that somewhat on these forums. Right now I'm concerned about the above item right now.
I know this should be real simple. I just am not good at String Management, with RichTextBoxes
Much Thanks in Advance.
-
Nov 14th, 2005, 09:47 PM
#2
Re: RichTextBox Find and Highlight Line with prefix
You can use the .Find method of the rtb to selectively highlight text.
-
Nov 14th, 2005, 09:49 PM
#3
Thread Starter
Addicted Member
Re: RichTextBox Find and Highlight Line with prefix
Yea, I'm aware of that.
However each selection will be different and can be auto created
So possible phrases
*Hello
*Bye
*TTYL
each line would be globally colored whatever, on the change event.
-
Nov 14th, 2005, 09:57 PM
#4
Re: RichTextBox Find and Highlight Line with prefix
-
Nov 14th, 2005, 10:01 PM
#5
Thread Starter
Addicted Member
Re: RichTextBox Find and Highlight Line with prefix
I've been checking that thread for 2 weeks now.
I tried practically every search phrase on google and here to find the solution...
Try... Search... Then Last Possible Senario Ask...
-
Nov 14th, 2005, 10:33 PM
#6
Hyperactive Member
Re: RichTextBox Find and Highlight Line with prefix
Are you looking to color each word that is prefixed with a * ?
If so, just search for the * and then from that starting point, search for a space or line feed and color what's inside.
-
Nov 15th, 2005, 10:32 AM
#7
Thread Starter
Addicted Member
Re: RichTextBox Find and Highlight Line with prefix
yes that is the plan. So I would use .Find and use Left functions.
Then carriage return is /n correct?
-
Nov 15th, 2005, 11:45 AM
#8
Re: RichTextBox Find and Highlight Line with prefix
Nope. Try the vbCrLf code.
-
Nov 15th, 2005, 12:50 PM
#9
Re: RichTextBox Find and Highlight Line with prefix
Originally Posted by DJHotIce
Then carriage return is /n correct?
I believe /n is C/C++ syntax.
-
Nov 15th, 2005, 05:24 PM
#10
Re: RichTextBox Find and Highlight Line with prefix
Try this
VB Code:
Option Explicit
Dim lStart As Long
Dim lEnd As Long
Dim Found As String
Private Function FindNext(lStart As Long, lEnd As Long, Found As String) As Boolean
FindNext = False
If lStart = 0 Then lStart = -1
lStart = RTB.Find("*", lStart + 1)
If lStart < 0 Then Exit Function
lEnd = InStr(lStart + 1, RTB.Text, vbCrLf)
Found = Mid(RTB.Text, lStart + 1, lEnd - lStart - 1)
FindNext = True
End Function
Private Sub Command1_Click()
If Not FindNext(lStart, lEnd, Found) Then
MsgBox "All Words Found"
Else
'do your highlighting here
MsgBox "Found: " & Found
End If
End Sub
Private Sub Form_Load()
RTB.SelText = "This is a test" & vbCrLf
RTB.SelText = "*Find" & vbCrLf
RTB.SelText = "Don't Find" & vbCrLf
RTB.SelText = "*Hello" & vbCrLf
RTB.SelText = "*There" & vbCrLf
RTB.SelText = "Skip me" & vbCrLf
RTB.SelText = "*Get" & vbCrLf
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|