.net - "Find Next" Functionality In RichTextBox: Include "Match Case"

May 20, 2011

I have very complicated, unnecessary code because I wrote it myself and this is a new concept to me. The code is intended to find a string in the main window's RichTextBox (the string is obviously supplied by the user). The code works fine, but due to its convoluted nature, I don't know how to implement a "Match case" function.

The form has these controls (at least the ones you use when searching for text):

Textbox: "txtFind" - User enters a search term here

Checkbox: "chkMatchCase" - Allows a user to choose whether or not to match the case of the search term

Button: "btnFind" - The Find Next button

And this is my code

Dim index As Integer = 0
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim strSearchTerm As String

[Code].....

Anyway, if there's a better way to implement this, please let me know. And I did extensive searching, but found no good solution. I ended up combining a bunch of little parts of other tutorials into this. If there's no better solution, I'd just like to know how to implement a "Match case" function.

View 1 Replies


ADVERTISEMENT

Forms :: RichTextBox - Search Feature And Match Case

Mar 28, 2011

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 highlight 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
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

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 matching 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.

View 4 Replies

DB/Reporting :: How To Include DB Info In RichTextBox

Jul 27, 2009

I have connected my database to visual basic.I have a form1 which allows me to scroll through all the data in my database (i.e. the name, account no, address etc)My form2 contains a calculation involving payments which involve the previous account.My form3 needs to contain this calculation PLUS the database information in a RichTextBox. My question is how do I include my DB info in a RichTextBox? (i.e how do I pass the information from form1 onto form3)

View 4 Replies

Change The Selected Value To Upper Case In The Richtextbox In 2008?

Sep 15, 2010

i need to change the selected value to upper case in the richtextbox i use the code

Dim tou As String
Dim tot As String
tou = RichTextBox1.SelectedText
tot = tou

[code]....

View 1 Replies

Bindingsource.find Without An Exact Match?

Dec 13, 2011

Private Sub btnRPSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnRPSearch.Click
Dim currentRecord As String = RprAuthNumTextBox.Text

[Code].....

View 2 Replies

Find All Paragraphs Of Match Type A NOT B?

Jul 30, 2009

Using regular expressions, how can we find all paragraphs of match type A NOT B E.g Find all paragraphs which has the word "pattern" but doesn't have the word "regular".So in the following text, 2 & 3 should be selected while 1 should be omitted:

1. With regular expressions you can describe almost any text pattern

2. including a pattern that matches two words near each other.

3. This pattern is relatively simple, consisting of three parts.

View 10 Replies

Find Match In MultiLine String?

Nov 21, 2010

i have a string named Workers that had multiple lines of text. I need to search those lines for the term "BackGroundWorker1" if it is found then do something if not do something.

View 3 Replies

Find Exact Match Of A Word In A Textbox If It Exists

Nov 20, 2011

I need a way to tell me if a certain word already exists in a multi-lined textbox. Right now I have a multi-lined textbox with some names inside it. After each name I add a newline so all the names are on their own line inside the textbox.I use this code to add names to the textbox, Text Box1. AppendText(ComboBox1.Text + vbCrLf)Then I have been checking if the name exists by doing it this way,[code]The problem is that Ted and Teddy return the same when searching for Ted even if Ted isnt in the textbox at all, I have googled for the last few days and even tried RegularExpressions and still the same results. I think this might be a simple true or false check but I may be wrong... or even a loop or something line by line.

View 5 Replies

Regex To Find Alphanumeric Match With Day Part Of Datetime?

Jan 5, 2012

I have to match string like "DAY1","DAY2","DAY3"....."DAY31" with regex in vb.net. I tried something like this - ^?DAY(0[1-9]|[12][0-9]|3[01])$ but it did not work.

The pattern should have succesfull match if the source string is either DAY1 or DAY2 or DAY3 to DAY31 like so.

View 1 Replies

Where To Look In A VB Backend To Find Parameters That Match Stored Procedures

Apr 8, 2009

I am building a module that uses gridview and formview to display data in a grid, using VB as my backend, developing in VS2008. When I try to implement the module, I receive an error about matching parameters.From what I have read, this error kicks back due to a discrepancy between the VB and the SQL stored procedures.My query should be totally okay, but I don't know where exactly I should be looking in my visual basic...I have five separate VB files; the view.vb file, edit.vb, settings.vb, the controller.vb, and info.vb.I had thought that my best bet might be the controller file, but I can seem to find anything that might be missing.

Error report to follow:
Parameter count does not match Parameter Value count. ---> System.ArgumentException: Parameter count does not match Parameter Value count. at

[code].....

View 1 Replies

Office Automation :: Find Strings That Match A Regular Expression?

Dec 28, 2009

Is it possible to use regex with Range.Find.Text or set the Word.Range according to a regex in word automation? I just want to find strings that match a regular expression an manipulate them.

View 2 Replies

.net - Write A Linq To Sql Query To Find Records Where Field Name Can Match One Of Dynamic Number Of Strings?

Mar 21, 2012

I have users check off lab facilities in a UI. I want to use linq to fetch corresponding records for all of the labs that they have checked off. Basically,

Dim myRecs = (From l As EpiData In myDataContext.EPIDatas Where l.facility= _
one of the checked labs

So basically, I need to write a linq query where the "strings" to match are determined at runtime. Is there any way to do this easily? I know that there is a library out there called dynamic LINQ, but (1) it's in C# and I'm writing in VB (2) I'm really just looking for a single, simple solution for this single case.

View 1 Replies

Find In List / Remove Item And Ignore Case Of Characters In String

May 20, 2012

I'm having issues with finding something in list, and removing the item, ignoring the case of characters in string.

The code goes:
Dim listItems As New List(Of String)
Dim pattern As String = "AbC"
Dim array() As String
array = {"ABC", "abc"}
listItems.AddRange(array)

Here I'd like to remove all items from listItems, that are abc, no matter what case single characters of item are, including mixed case items. So in this example, every items should be removed
listItems.Remove(listItems.Find(Function(r) r = pattern))

If I change pattern to match the case of item, then item #2 gets removed:
pattern = "abc"
listItems.Remove(listItems.Find(Function(r) r = pattern))
How can I find item in listItems, ignoring the case characters in pattern?

View 7 Replies

VS 2010 Visual Basic Debugger Error: Debugging Information For 'EXCEL.EXE" Cannot Be Found Or Does Not Match - Cannot Find Or Open The PDB File

Jun 19, 2009

Whether I am using VB 2008 Express or VS 2010 Beta 1 Visual Basic, I get the same error: "Debugging information for 'EXCEL.EXE" cannot be found or does not match. Cannot find or open the PDB file" I have filled in the Debug Tab information: Start external program: C:Program FilesMicrosoft OfficeOffice12Excel.exe

[Code]....

View 2 Replies

Find A Pattern In Richtextbox?

Jul 31, 2010

How do i find a pattern in richtextbox?[code]...

View 2 Replies

How To Get Sub To Find String In RichTextBox

Jan 27, 2009

I need a sub that can find a string in a rich textbox. I can find a string with the function .find but I need to focus the other string with that name...
EX: Hi lol hi hi
I need to find the first hi, but if I want I need to find the second hi, but I don't know how I can do it....

View 1 Replies

Richtextbox Find And Replace

Apr 17, 2012

I code in VB using VS2010..I have a richtextbox with variously coloured text.I use richtextbox.find to locate and highlight a word.I use richtextbox. replace to replace it with another word..The word is replaced - but all the colours disappear!

View 3 Replies

Use The Find Feature In A Richtextbox?

Feb 2, 2011

i need to create a find feature to find text inside of a richtextbox.

How can I do something like this? The web just takes me everywhere when I google it.

View 1 Replies

Find Cursor's X,y Coordinates In A Richtextbox?

May 15, 2008

how to find the x,y coordinates of where my cursor is in an editing control like richtextbox. I don't need the mousepointer coordinates but the editor's cursor position.I found this VB code to achieve this. How can I convert it to vb.net ? Or is there a simpler solution ?

View 6 Replies

Find The Words In Richtextbox That Has : (colon)?

Dec 16, 2011

how to find the words in richtextbox that has : (colon)?

View 2 Replies

Richtextbox And A Find And Replace Dialog?

Apr 20, 2010

I have a richtextbox and a find and replace dialog and I would like to change the location of the dialog relative to the word that is found so it doesn't hide the word. I have searched and searched and cannot find a way to find out the coordinates of the found word.

View 1 Replies

RichTextBox.Find With Reverse AND MatchCase?

Oct 21, 2010

How would I use Reverse and MatchCase at the same time in RichTextBox.Find?Or if you got a page that explain how to make "Find", "Find Next" and "Replace" functions,

View 2 Replies

VS 2005 Match Characters Of Combination Using RegEx.match?

May 29, 2010

Am trying to match characters or combination of the characters i specify in any order they appears

vb
Regex.IsMatch(teststring "[nuls]")

what i want matched is either any single character, or combination of any of them in any oder. this means that it should not match any character not specified in the pattern.

For example

it should match

n,u,l,s,nu,un,lun, sl etc

not

ny, nx so etc or any other

View 9 Replies

Find A Match For A String In Column 1, Return A Value From Column 2 On The Same Row?

Sep 25, 2009

i'm trying to get my program to look up a string and find a match in an access database in column "PhoneNumber" and return the value from column "FullName" on the same row to a different string

so it would go like this: (i really don't know much about accessing databases)

Dim PhoneNumber As String
Dim FullName As String
PhoneNumber = TextBox1.Text
FullName =

View 10 Replies

Find The Match For The String "date"?

Apr 17, 2009

finding out how to match a string. I am trying to find the match for the string "date". However it could exist in any of the following forms, "SAMPLE_DATE", "Date", "Sample date" "today's date" "Sampledate".

Is there any regular expression for this problem?

View 1 Replies

Find And Replace Text In A Richtextbox With A Xml File?

Aug 6, 2011

I have a small app for find and replace text in a richtextbox:

1-One button: Replace
2-Textbox1 : Find
3-Textbox2 : Replace for

But I want to know if is possible find and replace the text in the richtextbox with a xml file example:

Text in the richtextbox: "I will buy a car"
XML:
<pre lang="vb">

[Code]...

If is possible please can you give me a example code?

View 13 Replies

Make A Search Using Richtextbox.find Which Is Both MatchCase And Reverse

Dec 13, 2009

i'm trying to make a search using richtextbox.find which is both MatchCase and Reverse. how can i do this?

View 3 Replies

Make A Simple Find/FindNext/Replace RichTextBox?

Jun 26, 2010

simple and easy code to find/findnext/replace richtextbo

View 1 Replies

Read Upper And Lower Case Letters Without Having To Put The Upper Case Letters In Select Case Statement

Oct 28, 2009

i have a program using a select case to convert letters to special charaters. My question is how can I get the code to read upper and lower case letters without having to put the upper case letters in my select case statement. Example: Part of my code is

[Code]...

View 6 Replies

File I/O And Registry :: Find File Name Regardless Of Extension's Case?

Sep 15, 2009

I need to be able to find files in a folder where the extension can be either caps or small letters. Here's my code:

Code:
Public Function GetIcon(ByVal name As String) As Icon
Dim execAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly
Dim stream As System.IO.Stream =

[Code]....

How can I modify that function to return the file regardless of whether the extension is in caps or small letters?

This is in VS2005 for a .NET 2.0 Compact Framework project

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved