By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,806 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,806 IT Pros & Developers. It's quick & easy.

Code for standard Find / Replace dialog box

P: 12
Hi Everybody,
can anyone help in sending code reference to build a simple find dialog box like the one we call by (ctrl+F).

Thanks a lot.
Mar 29 '07 #1
Share this Question
Share on Google+
4 Replies


vijaydiwakar
100+
P: 579
Hi Everybody,
can anyone help in sending code reference to build a simple find dialog box like the one we call by (ctrl+F).

Thanks a lot.
whenevr CTrl+F is pressed open ur customised find dialog box
use Instr function to find the text
use selselect to select the text and use replace function to replace it
Try it
Good Luck
Mar 29 '07 #2

P: 12
Thanks for your immediate reply, my problem is i can't direct the search code to go to the next matching text (corresponding to Find Next). Once i got the first match, i need to pause the search, which i don't know how to resume in case of Find next is pressed. it always searches from the beginning and find the same match because i ended the procedure containg the search code.

One other question - sorry if being simple - how can i call the Find form i created by pressing the Ctrl+F.

Thanks again





whenevr CTrl+F is pressed open ur customised find dialog box
use Instr function to find the text
use selselect to select the text and use replace function to replace it
Try it
Good Luck
Mar 29 '07 #3

vijaydiwakar
100+
P: 579
Thanks for your immediate reply, my problem is i can't direct the search code to go to the next matching text (corresponding to Find Next). Once i got the first match, i need to pause the search, which i don't know how to resume in case of Find next is pressed. it always searches from the beginning and find the same match because i ended the procedure containg the search code.

One other question - sorry if being simple - how can i call the Find form i created by pressing the Ctrl+F.

Thanks again
for first part save the lacation of text and next time begin search from that point using mid$ function
for second part tress keydwn event of form
Mar 29 '07 #4

Robbie
100+
P: 180
for first part save the lacation of text and next time begin search from that point using mid$ function
for second part tress keydwn event of form
In the InStr() function there is an optional part 'Start':
Expand|Select|Wrap|Line Numbers
  1. InStr([Start], [String1], [String2])
[Start] tells it to start looking from this # character onwards in the string.
So you can just tell it the next time round to start to search from 'the position of wherever you found it last time' +1, so you don't find that same piece of text again.
An example...
Expand|Select|Wrap|Line Numbers
  1. LastPosition = InStr(LastPosition+1, String1, String2)
So that it updates the 'last position' with this new position, then it goes round again and loops...
That also means that once you've reached the end and not found the text you've told it to look for, then the next time you search it will start from position 0+1 i.e. it will restart from the begining like programs like WordPad do.
Mar 30 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.