Using the Find/Replace cdialog box in Visual basic

Merrion
10-03-2001, 09:51 AM
After days of frustration looking for examples of using the Find/Replace common dialog box from VB I gave up and wrote an example myself

Merrion
07-25-2002, 08:51 AM
Hmm - the code went missing...reposted...

OnErr0r
07-29-2002, 10:30 PM
Ah, very nice. I've had Find/Replace on my todo list for some time.

I noticed a few things. (I hope you don't mind me mentioning them)

There is no detection for search direction (up/down) and I guess you could do something like this:


Case .flags And FR_FINDNEXT
If (.flags And FR_DOWN) Then
Call FindNext(sFindWhat, (.flags And FR_WHOLEWORD), (.flags And FR_MATCHCASE))
Else
Call FindPrevious(etc...) ' or FindX with another param for direction
End If


I see the search direction is initially up. Might be nice to default to searching down *shrug*

It appear that the selected text is off by one.


If lNextPos > 0 Then
mTxtBox.SelStart = lNextPos - 1 ' I added the - 1
mTxtBox.SelLength = Len(psIn)
Else
Beep
End If


I also noticed two constant issues.

Chr$(0) could be vbNullChar (faster)
"" in ShellExecute could be vbNullString (preferable as "" often fails in apis)

Anyway, I'm glad you posted the code. Keep up the good work :)

Merrion
07-30-2002, 04:38 AM
Updated as per your comments...still an issue with match whole word in that I haven't coded it :-)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum