Results 1 to 2 of 2

Thread: Find Text

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Find Text

    Hi all!
    I’m in need of some assistance, and I hope that someone will explain this to me.
    I have added a search feature to my Text Pad but I cannot find any reference for what I’m trying to do.
    The first thing is a check box that when checked, will only display an exact match.
    The next thing would be 2 radio buttons in a group box. Obviously, one of which is up and the other one is down. And maybe, if someone feels like explaining it, I would also like to know how I can replace all instances of a word at one time.
    Here is the code that I'm using now.
    VB Code:
    1. Private Sub cmdFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFind.Click
    2.         Dim fMain As New frmMain
    3.         fMain = CType(Me.Owner, frmMain)
    4.         Dim lstr As String = fMain.tb1.Text()
    5.         Dim lstrFind As String = cmbFind.Text
    6.         Dim lintSelStart As Int64 = lstr.IndexOf(lstrFind, lintLastIndex)
    7.         If lintSelStart = -1 Then
    8.             fMain.tb1.Select(0, 0)
    9.             lintLastIndex = 0
    10.         Else
    11.             fMain.tb1.Select()
    12.             fMain.tb1.Select(lintSelStart, lstrFind.Length)
    13.             lintLastIndex = lintSelStart + 1
    14.         End If
    15.  
    16.     End Sub
    17.  
    18.     Private Sub cbCase_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCase.CheckedChanged
    19.         If cbCase.Checked Then
    20.             'To do: need code to display only exact match
    21.         End If
    22.     End Sub
    23.  
    24.     Private Sub cmdReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReplace.Click
    25.         Dim fMain As New frmMain
    26.         fMain = CType(Me.Owner, frmMain)
    27.         fMain.tb1.SelectedText = tbReplace.Text
    28.     End Sub
    29.  
    30.     Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
    31.         Me.Close()
    32.     End Sub

    Thanks in advance for any help!
    Last edited by Rally2000; Mar 5th, 2004 at 02:42 AM.
    Code:
    Dim R1 As Fast 
    Dim Kawasaki As crap
    Dim rash As necessary
    If Kawasaki onRoad = True Then
        R1.runoverKawasaki
    Kawasaki = rash

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Well, I don't have time to conjure up code for you, sorry.

    But I could give you what I would say is the roadmap I would employ.

    Basically, you will have to examine your document by starting at the beginning character, shifting forward one character at a time, toward the end (Count), pausing whenever a match is found.

    So... a search for hat would return..

    medhat, hate, hatch

    If its an exact match (whole word only), things get just a tad bit more involved, in that you need to check if the match has either:
    1) hat! (space plus punctuation)
    2) .Hat (punctuation plus space)
    3) hat (with two spaces on either side)
    4) hat (space, and the word hat being the last three characters of the document)

    There are a few helpful functions of the Char class called IsPunctuation , IsSeperator, IsWhiteSpace that will return true on punctuation and spaces, and you can easily check if hat is at the end of a document with a space before it as well.

    Have fun!

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