|
-
Mar 5th, 2004, 02:39 AM
#1
Thread Starter
Addicted Member
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:
Private Sub cmdFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFind.Click
Dim fMain As New frmMain
fMain = CType(Me.Owner, frmMain)
Dim lstr As String = fMain.tb1.Text()
Dim lstrFind As String = cmbFind.Text
Dim lintSelStart As Int64 = lstr.IndexOf(lstrFind, lintLastIndex)
If lintSelStart = -1 Then
fMain.tb1.Select(0, 0)
lintLastIndex = 0
Else
fMain.tb1.Select()
fMain.tb1.Select(lintSelStart, lstrFind.Length)
lintLastIndex = lintSelStart + 1
End If
End Sub
Private Sub cbCase_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCase.CheckedChanged
If cbCase.Checked Then
'To do: need code to display only exact match
End If
End Sub
Private Sub cmdReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReplace.Click
Dim fMain As New frmMain
fMain = CType(Me.Owner, frmMain)
fMain.tb1.SelectedText = tbReplace.Text
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Me.Close()
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
-
Mar 5th, 2004, 08:59 AM
#2
I wonder how many charact
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|