473,473 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

string.IndexOf help

In my project I want to search thru a text in a text box or RichTextBox.

When I search I want to list all lines that contain the string I am
searching for.

e.g.

one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five

search for the string "one", and display the contents of all lines in the
TextBox/RichTextBox.

I envision that the TextBox/RichTextBox would be a control that is hidden
normally and then the search form would resize and show the
TextBox/RichTextBox control with the results.

Could someone please post a sample?

Thanks,

Brian
Aug 22 '07 #1
3 1796
Hello, Brian

so what exactly are you looking for? example of searching that
richtextbox or resizing form?
im sure nobody has the will to make programs for you but surely
someone may help if you have precise questions.

sorry for my english:P

On Aug 22, 3:30 am, Brian Cook <brian.c...@bnsf.comwrote:
In my project I want to search thru a text in a text box or RichTextBox.

When I search I want to list all lines that contain the string I am
searching for.

e.g.

one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five

search for the string "one", and display the contents of all lines in the
TextBox/RichTextBox.

I envision that the TextBox/RichTextBox would be a control that is hidden
normally and then the search form would resize and show the
TextBox/RichTextBox control with the results.

Could someone please post a sample?

Thanks,

Brian

Aug 22 '07 #2
Hi,
I think you are looking for something like below:
static int previndex;
private void button1_Click(object sender, System.EventArgs e)
{
for(int lineno = 0;lineno < richTextBox1.Lines.GetLength(0);lineno++)
{
previndex = richTextBox1.Find("one",previndex,RichTextBoxFinds .WholeWord
);
int richtextboxlineno =
richTextBox1.GetLineFromCharIndex(richTextBox1.Fin d("one",previndex,RichTextBoxFinds.WholeWord ));
if (previndex ==0 )
{
previndex++;
}
richTextBox2.AppendText(richTextBox1.Lines[richtextboxlineno]);
}
}
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Brian Cook" wrote:
In my project I want to search thru a text in a text box or RichTextBox.

When I search I want to list all lines that contain the string I am
searching for.

e.g.

one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five

search for the string "one", and display the contents of all lines in the
TextBox/RichTextBox.

I envision that the TextBox/RichTextBox would be a control that is hidden
normally and then the search form would resize and show the
TextBox/RichTextBox control with the results.

Could someone please post a sample?

Thanks,

Brian
Aug 22 '07 #3
Hi Rammer, I am looking for a sample/snipit of how to utilize the IndexOf
method that makes better sense than the ones on the MSDN Library.

I am just not grasping that one.

"rammer" wrote:
Hello, Brian

so what exactly are you looking for? example of searching that
richtextbox or resizing form?
im sure nobody has the will to make programs for you but surely
someone may help if you have precise questions.

sorry for my english:P

On Aug 22, 3:30 am, Brian Cook <brian.c...@bnsf.comwrote:
In my project I want to search thru a text in a text box or RichTextBox.

When I search I want to list all lines that contain the string I am
searching for.

e.g.

one plus four
two plus four
three plus four
one minus four
one divided by four
two minus four
two divided by four
three plus five
three minus five

search for the string "one", and display the contents of all lines in the
TextBox/RichTextBox.

I envision that the TextBox/RichTextBox would be a control that is hidden
normally and then the search form would resize and show the
TextBox/RichTextBox control with the results.

Could someone please post a sample?

Thanks,

Brian


Aug 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
4
by: Jason Gleason | last post by:
What's the most efficient way to get the number of occurences of a certain string in another string..for instance i'm using the following code right now... private int CharacterCounter(String...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
2
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
8
by: Ben Dewey | last post by:
Anyone, I am trying to do a string replace of a custom Html Tag that is Case Insensitive and Fast, I will be calling this function a bunch of times. Any thoughts about using maybe a...
10
by: Learner | last post by:
Hello, I am trying to create few dynamic controls and once they are rendered I need to save the information that was entered into these dynamic fileds. For instance when I create 3 radio button...
8
by: SMJT | last post by:
Does anyone know why the string contains function always returns true if the token is an empty string? I expected it to return false. "AnyOldText".Contains("") or...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.