|
-
May 27th, 2011, 07:11 PM
#1
Thread Starter
Fanatic Member
Searching up through richtextbox (not down)
I've been trying to figure this out lately by looping a richtextboxfinds code replacing the integer with a value -1 than the integer before it after the starting string in that code. But for some reason I can't get it to loop through my text upwards.
It loops down through the text fine, however i'm not satisfied with that loop either, it seems a bit buggy.
vb Code:
Dim x As Integer If searchdown.Checked Then 'We'll define fOption as the richtextbox finds option for searching the text Dim fOption As RichTextBoxFinds = 0 If ckCaseSensitive.Checked Then fOption = fOption Or RichTextBoxFinds.MatchCase If ckWholeWord.Checked Then fOption = fOption Or RichTextBoxFinds.WholeWord x = Form1.RichTextBox1.Find(txtFind.Text, PlaceHolder, fOption) PlaceHolder = Form1.RichTextBox1.SelectionStart + 1 If x < 0 Then If MessageBox.Show("There are no more occurances of the text " & txtFind.Text & vbCrLf & "or the text does not exist in the document. Would you like to start from the beginning of the document?", "Not found", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then PlaceHolder = 0 btnFindNext.PerformClick() End If End If
With using selection start -1 to get the integer to reduce in value it doesn't seem to want to use that placeholder to search upward through the text. And It wouldn't seem that the reverse code for richtextboxfinds would be appropriate for this either, i've tried using the value for it (16) in the code with a few different methods and nothing seemed to work for me.
Anyone want to help me understand what i'm doing wrong here, or if there's anything I could do to better my downsearch/upwardsearch
The down search seems to take 2 clicks on my button handler to actually change the selected text that it finds, and then I used the code for an upward search, it would search one more down upon pressing my "search up" button, before not doing anything after that on the next click. So i'd assume something is wrong with the down search function as well.
Last edited by AceInfinity; May 27th, 2011 at 07:17 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|