Results 1 to 11 of 11

Thread: API for search and replace

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    is there an API that allows the search and replace that is found in notepad for a standard text box?
    I am asking because it seems like you can do a lot of standard things with the API like cut/copy/paste/undo ect.
    also the API seems to be much faster then code written in VB.
    What is the down side to using the API, and why don't they teach it more in school? The only thing we did with it was to play a wav file. Not that wav files are unimportant but it seems that the API is a huge asset to windows programming. sorry for rambling
    thank you for your time and have a good day

    ------------------
    I am so skeptacle, I can hardly believe it!

  2. #2

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    I knew that the API could not do everything!

    ------------------
    I am so skeptacle, I can hardly believe it!

  3. #3
    Member
    Join Date
    Nov 1999
    Location
    Dover, NH
    Posts
    54

    Post

    This is a great question. I'd be curious about the answer as well. Are Sergio and Aaron on vacation? They would surely know the answer.

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    why not use the VB Replace function? It does the same thing w/o the API hassle...

    Replace Text1.Text, "StringToFind", "StringToReplace"

  5. #5

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    it is starting to seem like the API is not a hassel for some people. For me it is a hassel but I think that if I try to use it, I may find it to be less of a hassel after a while.
    My goal with this question was to see if the search and replace function was something I could call. It would be less code and run faster then any code I could write. Also, I need to make a form for the user to input the search string and such. This will take up space and resources. I wanted to find out if I was re-inventing the wheel here.
    thank you for your time and have a good day

    ------------------
    I am so skeptacle, I can hardly believe it!

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    APIs are not a hassle if you know what parameters go where, but if you don't, it's like banging your head against a brick wall.

  7. #7

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    can these API calls be used for a search and replace. I am asking because I am fumbling through this API thing. Does the p in pFindreplace mean pointer?
    Public Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" (pFindreplace As FINDREPLACE) As Long
    Public Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA " (pFindreplace As FINDREPLACE) As Long
    Thank you for your time and have a good day

    ------------------
    I am so skeptacle, I can hardly believe it!

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    It is more easy to do this in VB. The FINDREPLACE structure is difficult to use in VB (it contains pointers to strings) and was built with VC++ in mind. Also the ReplaceText and FindText api calls do nothing more then pop up a dialog box. They do not find or replace anything. To use this (and I believe not all Windows OS's support them) you need to create a callback function that handles the actual find and replace. I gave it a shot, but I gave up after a few hours. Maybe someone else can help you out, but it involves very serious coding.

  9. #9
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    That REPLACE function example I posted earlier just keeps looking better and better.....

    If you want to have an interactive find/replace (like M$ Apps), you can probably accomplish it by using InStr to get the position of the word, highlight it, prompt for change, and use instr again to find the next instance of that word. Keep going until the result of instr = 0 -- be sure to keep incrementing InStr's START parameter....

    Tom

  10. #10

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    thank you everyone for your time and input.

  11. #11
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    There are a lot of good books about the API which are definitely worth reading.
    As far as the Find/Replace dialog, it's declared in the comdlg dll, so it only gives you the interface, you still need to do the replace coding yourself (so yes, the VB 6 Replace function is pretty easy....).
    If you really want to use a find/replace dialog, create one yourself... not that a\hard and lots easier to use I think...

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