Results 1 to 5 of 5

Thread: i need help with finding text

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    6

    Post

    i made a word processor, and now i need want to put a "search" feature on it. How do i code it?

    so far i have this:

    FindOver = False
    SearchPos = 0
    FindText Text, Find
    Text.SelStart = SelTextFrom
    Text.SelLength = SelTextTo

    but, that doesn't work....

    can anyone help me????

    thanks, kirkhammet

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Post

    Originally posted by kirkhammet:
    i made a word processor, and now i need want to put a "search" feature on it. How do i code it?


    so far i have this:

    FindOver = False
    SearchPos = 0
    FindText Text, Find
    Text.SelStart = SelTextFrom
    Text.SelLength = SelTextTo

    but, that doesn't work....

    can anyone help me????

    thanks, kirkhammet
    how's this for quick service?

    try:
    Code:
    dim findThis as string
    findthis = myform.findTextBox.text
     FindOver = False
     SearchPos = 0
     FindText Text, Find
     Text.SelStart = 0
     Text.SelLength = len(findthis)
    if text.seltext = findthis then
    msgbox "String Found"
    if this doesn't work, email me your program and i will fix it for you!


    ------------------
    david
    Teenage Programmer


  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    6

    Post

    i need to know what the code for the sub "FindText" is ... and i need to know what goes in the parenthesis

    kirk

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    I made a function to do this!
    here ya go:
    Code:
    Public Function FindText(TextBox As TextBox, TextString As String)
    TextBox.SetFocus
    If InStr(TextBox.Text, TextString) > 0 Then
    TextBox.SelStart = InStr(TextBox.Text, TextString) - 1
    TextBox.SelLength = Len(TextString)
    Else
    MsgBox "Text '" & TextString & "' not found!", 16, "Error"
    End If
    End Function
    
    Private Sub Command1_Click()
    FindText Text1, "Hello"
    End Sub
    If the text is found it HighLights it. If not you get an error message that says it's not found!

    ------------------
    DiGiTaIErRoR
    VB, QBasic, Iptscrae, HTML
    Quote: There are no stupid questions, just stupid people.


    [This message has been edited by DiGiTaIErRoR (edited 02-20-2000).]

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    6

    Post

    good one!, but i need to know how you make it work when you input the string you want it to search for. i.e. you type in a word, and hit search... then it finds it. how do you do that?


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