Results 1 to 3 of 3

Thread: Search Textbox help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 1999
    Location
    Scarbrough, Maine, USA
    Posts
    17

    Post

    Alright - I have tried everything in here. I am trying to highlight certain tex in a textbox. I already have the code to open, a file to the textbox and I know how to see if the string is in a textbox. I am using Instr(LCase(Text1.text)), LCase(X)) to find the text and tell me if it's there bu now I need to highlight the text. I would also like to know how to find the NEXT match in the textbox if you guys could help me with that. Thanks a lot guys/gals


    ------------------
    Noman

  2. #2
    Guest

    Post

    to highlight text....

    Code:
    text1.selstart = (instr()...)
    text1.sellength = 10 'or whatever the length of the word is.
    to do the equivalent of Next, all you need to do is run the Instr() function again but use (selstart + 1) as the start point!


    ------------------

    Wossname,
    Email me: [email protected]

  3. #3
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    Here is the code that I'm sending you:

    Option Explicit

    Const pSTART = 1

    Dim nLastStop As Long

    Private Sub cmdNext_Click()

    Dim cFind As String
    cFind = UCase$(txtFind.Text)

    Dim cText As String
    cText = UCase$(Text1.Text) 'If cache variables your program became faster

    Dim nPos As Long

    On Error Resume Next
    If nLastStop >= Len(cText) Then
    MsgBox "No more text to find!", vbInformation
    Exit Sub
    End If

    nPos = InStr(nLastStop, cText, cFind)

    Text1.SelStart = nPos - 1
    Text1.SelLength = Len(cFind)
    'Text1.SelText = Mid$(cText, nPos, Len(cFind))

    nLastStop = nPos + Len(cFind)

    End Sub

    Private Sub Form_Load()

    'YOU MUST SET THIS PROPERTY TO TRUE
    'IN DESING MODE IN ORDER TO WORKS.

    txtFind.text = "HOME"

    'Text1.HideSelection = False
    Text1.Text = "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home." & vbCrLf & _
    "Jefferson is at home."
    nLastStop = pSTART
    End Sub

    Private Sub txtFind_Change()
    'This clear and make find from begin!
    nLastStop = pSTART
    End Sub

    Boa sorte,
    Jefferson

    [This message has been edited by JeffSM (edited 01-22-2000).]

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