Results 1 to 5 of 5

Thread: How to scroll with highlighting in a textbox

  1. #1

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510

    Question 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!!


  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Rich Textbox on the form called RTB. A file on the C: called file.txt containing line returns
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim i As Long
    3. Open "C:\file.txt" For Input As #1
    4.   rtb.Text = Input$(LOF(1), 1)
    5. Close #1
    6. i = 1
    7. rtb.SelStart = i
    8. rtb.SelLength = InStr(i, rtb.Text, vbCrLf)
    9. Do Until InStr(i, rtb.Text, vbCrLf) = 0
    10.   rtb.SelStart = i
    11.   rtb.SelLength = InStr(i, rtb.Text, vbCrLf) - i
    12.   ProcessText rtb.SelText
    13.   i = InStr(i, rtb.Text, vbCrLf) + 1
    14. Loop
    15. End Sub
    16.  
    17. Public Sub ProcessText(strData As String)
    18. 'you can do whatever you want to process it here...
    19. MsgBox strData
    20. End Sub
    <removed by admin>

  3. #3

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    You are mad genius!!! Your routine works perfectly and I have implemented it into my program.

    Thanks for your help!

  4. #4

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    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!!


  5. #5
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

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