Home All Groups Group Topic Archive Search About

Searching for text in Text boxes

Author
13 Oct 2005 4:19 PM
David
Hi all

Newbie question I want to be able to search a text box for text from my
program in the way similar to Find (Ctrl+F) does is there any code or a
control that can do this ?

Author
13 Oct 2005 4:26 PM
Bob Butler
"David" <Da***@discussions.microsoft.com> wrote in message
news:7DBB4ACA-C65F-47EE-AC8B-927AD11653C8@microsoft.com
> Hi all
>
> Newbie question I want to be able to search a text box for text from
> my program in the way similar to Find (Ctrl+F) does is there any code
> or a control that can do this ?

A textbox in the same application?  The Instr or InstrRev functions? 

If not then you need to provide more info.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
13 Oct 2005 4:41 PM
David
Hi

I import a text file to a text box, I then want to be able to search that
text for specific words i.e. "football" and have it highlight it.


Show quoteHide quote
"Bob Butler" wrote:

> "David" <Da***@discussions.microsoft.com> wrote in message
> news:7DBB4ACA-C65F-47EE-AC8B-927AD11653C8@microsoft.com
> > Hi all
> >
> > Newbie question I want to be able to search a text box for text from
> > my program in the way similar to Find (Ctrl+F) does is there any code
> > or a control that can do this ?
>
> A textbox in the same application?  The Instr or InstrRev functions? 
>
> If not then you need to provide more info.
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
>
Author
13 Oct 2005 4:47 PM
Bob Butler
"David" <Da***@discussions.microsoft.com> wrote in message
news:6A6385A9-0B14-47E5-940E-EC845CA926EC@microsoft.com
> Hi
>
> I import a text file to a text box, I then want to be able to search
> that text for specific words i.e. "football" and have it highlight it.

If it is only 1 occurrence then a textbox is fine and the Instr function,
along with the SelStart and SelLength properties of the textbox will do it.

If you need to highlight the word in multiple places then you'll need to use
a richtextbox and do something like change the SelForeColor to highlight the
words

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
13 Oct 2005 4:39 PM
alpine
On Thu, 13 Oct 2005 09:19:03 -0700, "David"
<Da***@discussions.microsoft.com> wrote:

>Hi all
>
>Newbie question I want to be able to search a text box for text from my
>program in the way similar to Find (Ctrl+F) does is there any code or a
>control that can do this ?

You can use the FindText API function in comdlg32.  For more info,
have a look at the following link (watch for wordwrap).

[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxfunctions/findtext.asp]

HTH,
Bryan
_______________________________
Bryan Stafford
New Vision Software
newvision_don'tspam@mvps.org