|
-
Aug 13th, 2002, 03:54 PM
#1
Thread Starter
Hyperactive Member
How to scroll with highlighting in a textbox
My users load up a text file into a RichTextBox. My program then reads their text file line by line and does some operations requested by the user on each line.
I have a label that displays what line # the program is currently processing, but I would like to actually highlight that line in the RichTextBox where their file is loaded, so they can see the actual line being processed.
So, once the program started, it would highlight line 1 in the RTB and when the program moved to the next line it would highlight line 2 and so on.
It would scroll the file before your eyes and be beautiful... BUT I can't figure it out!
Any tips or leads greatly appreciated!!
-
Aug 13th, 2002, 06:09 PM
#2
PowerPoster
Rich Textbox on the form called RTB. A file on the C: called file.txt containing line returns
VB Code:
Private Sub Command1_Click()
Dim i As Long
Open "C:\file.txt" For Input As #1
rtb.Text = Input$(LOF(1), 1)
Close #1
i = 1
rtb.SelStart = i
rtb.SelLength = InStr(i, rtb.Text, vbCrLf)
Do Until InStr(i, rtb.Text, vbCrLf) = 0
rtb.SelStart = i
rtb.SelLength = InStr(i, rtb.Text, vbCrLf) - i
ProcessText rtb.SelText
i = InStr(i, rtb.Text, vbCrLf) + 1
Loop
End Sub
Public Sub ProcessText(strData As String)
'you can do whatever you want to process it here...
MsgBox strData
End Sub
-
Aug 14th, 2002, 09:28 AM
#3
Thread Starter
Hyperactive Member
You are mad genius!!! Your routine works perfectly and I have implemented it into my program.
Thanks for your help!
-
Aug 14th, 2002, 09:48 AM
#4
Thread Starter
Hyperactive Member
Any idea how I can change the color of the highlighting?
Thanks again for your expertise. I have been researching this to no avail for awhile. FINALLY the Messiah has come!!
thanks again!!
-
Aug 14th, 2002, 10:10 AM
#5
PowerPoster
I think the highlight color has something to do with the system colors, but there is probably a way to subclass it. I don't have any expertise in subclassing, so you could probably make a new thread about it.
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
|