Results 1 to 3 of 3

Thread: [RESOLVED] SelLength Problem.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    85

    Resolved [RESOLVED] SelLength Problem.

    I'm using this piece of code to select a small length of text on my text box.

    Code:
    Private Sub Command1_Click()
       Dim lngPos As Long
        Dim searchText As String
       
       searchText = Text1.Text
       If searchText = "Find what?" Then Exit Sub
       lngPos = InStr(1, txtData.Text, searchText, vbTextCompare)
       If lngPos > 0 Then
            Text1.BackColor = &H80FF80
            txtData.SelStart = lngPos - 1
            txtData.SelLength = Len(searchText)
            Timer1.Enabled = True
            Command2.Visible = True
       Else
            Text1.BackColor = &H8080FF
            Timer1.Enabled = True
       End If
    End Sub
    It seems to be working alright, but I can't see the area of text being selected. I mean, if the text is there, the back of the search box shows up green, like i've set it up to do and if it's not, it shows up red. I just cant see area of text being selected. It's strange...

    Any ideas?

    Syrillia
    Last edited by syrillia; Feb 27th, 2009 at 11:37 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SelLength Problem.

    I think you need to highlight individual lines of text, and you can't do that with a regular textbox. Switch to a richtextbox, and I think you will have better results.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    85

    Re: SelLength Problem.

    I'm using richtextbox. It works, 100% apart from the fact that I can't see the highlight.

    I've got a 'Find More' command that will look for more instances of the variable. So if I've got the word 'import' written 10 times; the find will find the first one, then find more will find the next 9. But after that it doesn't work.

    EDIT: I found out what it is. I cant see it because when I click the find button, the textbox is losing it's focus. Thanks for the help,

    Syrillia
    Last edited by syrillia; Feb 27th, 2009 at 11:36 AM.

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