Results 1 to 3 of 3

Thread: need a loop for Highlighting more word then one

  1. #1

    Thread Starter
    Hyperactive Member goofan's Avatar
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    296

    Exclamation need a loop for Highlighting more word then one

    Hi i got this program that searches throught files for a word or more words then 1. and all the files desplayes in a listbox (list1) and when i press on any of the "files" in the listbox i get the content in another window textbox...
    right now i can highlight the last "looped" word but i wanna highlight all the found words in the content...
    plz help me if u can.

    code:
    Code:
    Private Sub lbdraw_click()
    dim numberoffile as stringdim varde as string
    dim impa as string
    dim content as string
    dim myfilenum as string
    
    
    
    searchfor = (text1.text)
    words() = split(searchfor)
    
    dim i as integer
    dim tempstr as string
    
    For i = 0 To Ubound(words)
    tempstr = replace(words(i), ",", "")
    tempstr = replace(tempstr, ";", "")
    e.t.c.
    
    
    Next i
    
    
    
    
    List1.text = ""
    
    numberOfFile = lbdraw.ListIndex
    
    varde = filearray(numberOfFile)
    
    myfilenum = FreeFile()
    
    open varde For Input As #myfilenum
    Do While Not EOF(myfilenum)
      line input #myfilenum, impa
      impa = impa &vbNewLine
      content = content + impa
    Loop
    
    List1.text = content
    
    Close #myfilenum
    
    Dim talTest as integer
    talTest = 0
    talTest = instr(content, Tempstr)
    
    List1.setfocus
    If talTest <> 0 Then
      List1.selstart = talTest - 1
      List.selLength = Len(tempstr)
    Else
      List1.selstart = talTest
      List.selLength = Len(tempstr)
    End If
    End Sub
    Last edited by goofan; Nov 18th, 2009 at 04:26 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: need a loop for Highlighting more word then one

    you can not select more than 1 selection in a textbox


    change your textbox for a richtextbox, you can then use highlighting (not selecting), to highlight multiple ranges
    there is a thread by moeur in vb6 codebank, for working with richtextbox, including highlighting
    Last edited by westconn1; Nov 18th, 2009 at 05:49 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Hyperactive Member goofan's Avatar
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    296

    Re: need a loop for Highlighting more word then one

    ok thanks

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