SEARCH&REPLACE in textBox

  • Thread starter Thread starter Tomomichi Amano
  • Start date Start date
T

Tomomichi Amano

Could some one tell me how I can seach and replace only one word in a
textBox (THE FIRST WORD THAT COMES AFTER THE CURSOR). I already know how to
replace ALL , but I don't know how to REPLACE one, and how to SEARCH one and
select that point.

Thank in advance
 
You need to change the .Text property of the textbox to whatever the new
text should be. Presumably, you'd the SelectionStart property to determine
where to start looking, then find the first space (or other delimiter) there
or after there by using the IndexOfAny() method on the string, then find the
next delimiter using the same method but starting later in the string.
Finaly you would reassemble the text by taking the appropriate substrings of
the original (before and after the word) and building a new string from
them.
 
Back
Top