Hi there,
First of all, I'm quite new to VB.NET so would like to request for simple explanations, and apologies if my question is beginner-like.
Here's the situation:
I've got a form that has
- RichTextBox
- OpenButton (to load RTF file)
- SaveButton (to save RTF file after editing)
- Textbox (for search phrase)
- SearchButton
- ExitButton
- 2 RadioButtons (WholeWord and MatchCase search)
All of them are working just the way I want them to EXCEPT search features; I don't know how to write them properly.
At the moment, they search and hightlight ONLY the first word they encounter.
E.g. say I search for word "the" in the document, only the first "the" it encounters is highlighted. The rest is just untouched.
I understand this is because I've only got few lines of simple code as follows
I did try a few other snippets I found on the Internet including While loop but they didn't work as I wanted them to, and I couldn't understand them either.
What I want is, which ever search option is used, when the matchig result is found; it will highlight that word and when I click it again it will move onto another word. If I keep clicking, it will highlight the same words (but located in different areas) throughout the whole document and at the end, it will send back to the first matching word.
Just like Adobe Reader search.
Is it possible? Please help me out and I would be most appreciated if you could provide me a simple solution. This is not for professional use so as long as it works, I'd be happy
Thank you very much.
Regards,
vb_noob
EDIT: I've just realised that this thread is probably under the wrong location. I misread "VS.NET General Discussion" with "VB.NET General Discussion".
So, anyone who's in charged, please feel free to re-locate this thread. Sorry about this, folks.
First of all, I'm quite new to VB.NET so would like to request for simple explanations, and apologies if my question is beginner-like.
Here's the situation:
I've got a form that has
- RichTextBox
- OpenButton (to load RTF file)
- SaveButton (to save RTF file after editing)
- Textbox (for search phrase)
- SearchButton
- ExitButton
- 2 RadioButtons (WholeWord and MatchCase search)
All of them are working just the way I want them to EXCEPT search features; I don't know how to write them properly.
At the moment, they search and hightlight ONLY the first word they encounter.
E.g. say I search for word "the" in the document, only the first "the" it encounters is highlighted. The rest is just untouched.
I understand this is because I've only got few lines of simple code as follows
VB.NET:
If rtfText.Find(txtSearch.Text, RichTextBoxFinds.WholeWord) = -1 Then
MessageBox.Show("No results returned. Please try again.", "No matching results.", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
What I want is, which ever search option is used, when the matchig result is found; it will highlight that word and when I click it again it will move onto another word. If I keep clicking, it will highlight the same words (but located in different areas) throughout the whole document and at the end, it will send back to the first matching word.
Just like Adobe Reader search.
Is it possible? Please help me out and I would be most appreciated if you could provide me a simple solution. This is not for professional use so as long as it works, I'd be happy
Thank you very much.
Regards,
vb_noob
EDIT: I've just realised that this thread is probably under the wrong location. I misread "VS.NET General Discussion" with "VB.NET General Discussion".
So, anyone who's in charged, please feel free to re-locate this thread. Sorry about this, folks.
Last edited: