|
-
Mar 16th, 2001, 03:01 PM
#1
Thread Starter
Good Ol' Platypus
They wont listen to be at the General or API forums. You will only listen to me if I post here, so here I go.
I've got a Q. I've been trying to use the RTB control to do an editing environment, but it's not working. I want all of the words in the box that are in the Keywords() array to become blue, like in VB. Now I've tried:
1. Finding them and modifying them to no avail.
2. Having a second off-screen RTB and changing them there. Works, but always sets the caret to the start of the document, resulting in backwards text:
Here is my text.
.txet ym si ereH
Is there any other control where I can use HTML-like formatting to do this? Or is there an alternative to the rich text box? I dont want to use an RTB or something that looks unproffesional, for this is for my upcoming APP, JavaPad, freeware for Java Programmers.
Can you guys help me?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 16th, 2001, 03:13 PM
#2
PowerPoster
poor guy 
I think your problem is to always set the position of the cursor... SelStart=...
no time to test that out, sorry
-
Mar 16th, 2001, 03:46 PM
#3
Mmk. Here I go. Its pretty simple. First, for the highlighting funtion.
Code:
Private Sub highlight()
rtb.SelStart = 1
rtb.SelLength = Len(Box.Text)
rtb.SelColor = RGB(0, 0, 0)
For j = 0 To numkeywords - 1
For i = 1 To Len(rtb.Text)
If InStr(i, LCase(rtb.Text), LCase(keywords(j))) Then
With rtb
.SelStart = InStr(i, LCase(rtb.Text), LCase(keywords(j))) - 1
.SelLength = Len(keywords(j))
.selcolor = RGB(0, 0, 255)
End With
i = InStr(i, LCase(rtb.Text), LCase(keywords(j)))
End If
Next i
Next j
End Sub
That finds all of the keywords, and highlights them.
To make it work well, only use that sub when the user presses Enter, Up or Down.
Z.
[edit]
FIxed the highlight function. Now it clears the previous highlights before highlighting.
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
|