Code for standard Find / Replace dialog box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmed Yasser
    New Member
    • Feb 2007
    • 12

    Code for standard Find / Replace dialog box

    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.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Ahmed Yasser
    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

    Comment

    • Ahmed Yasser
      New Member
      • Feb 2007
      • 12

      #3
      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





      Originally posted by vijaydiwakar
      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

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by Ahmed Yasser
        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

        Comment

        • Robbie
          New Member
          • Mar 2007
          • 180

          #5
          Originally posted by vijaydiwakar
          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':
          Code:
          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...
          Code:
          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.

          Comment

          Working...