Click to See Complete Forum and Search --> : API for search and replace
badgers
Dec 28th, 1999, 03:34 AM
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 :D
thank you for your time and have a good day
------------------
I am so skeptacle, I can hardly believe it!
badgers
Dec 28th, 1999, 08:59 PM
I knew that the API could not do everything!
------------------
I am so skeptacle, I can hardly believe it!
tpatten
Dec 28th, 1999, 10:07 PM
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.
Clunietp
Dec 29th, 1999, 12:25 AM
why not use the VB Replace function? It does the same thing w/o the API hassle...
Replace Text1.Text, "StringToFind", "StringToReplace"
badgers
Dec 29th, 1999, 01:47 AM
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!
Clunietp
Dec 29th, 1999, 10:01 AM
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.
badgers
Dec 30th, 1999, 11:13 AM
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!
Frans C
Dec 30th, 1999, 10:41 PM
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.
Clunietp
Dec 30th, 1999, 10:57 PM
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
badgers
Jan 2nd, 2000, 10:12 PM
thank you everyone for your time and input.
Crazy D
Jan 3rd, 2000, 11:15 AM
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...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.