how to compare words in all richtextbox regards on what line and position?

poringgunner

Active member
Joined
Feb 23, 2014
Messages
42
Programming Experience
Beginner
how can i compare words in richtextbox?
example this is the contents of richtextbox1.
"how do i compare words in richtextbox
i dont know hos to start it"
and this is the richtextbox2 contents
"just follow the words in richtextbox
and you can start"

now this is my question.. how can i compare the word "how" to all words in line1 in richtextbox2? same procedure to all words in richtextbox1?
 
You can get a String from the Text of the RichTextBox and call its Spilt method to split on the spaces into an array of words. You can then use nested foreach loops to compare each pair of words. You'll probably want to throw in a Replace or Trim call at some point to remove punctuation.
 
how can i determine the first word? example "how" how do i know what will be i used to compare to others?
i already replace the punctuations.
 
how can i determine the first word? example "how" how do i know what will be i used to compare to others?
i already replace the punctuations.
String.Split returns an array so you can simply take the first element from that if you want the first word. If you want to access every item in an array then you use a 'for' or, preferably, a 'foreach' loop. If you want to compare one word in one array to every word in the other then you'd need one loop; if you want to compare all words in one to all words in the other then you'd need two nested loops. If you are only interested in the words themselves then use 'foreach' loops but if you are interested in the positions of the words then use 'for' loops.
 
i understand.. but i dont know how to start, can u give an example for "foreach and "for?
Loops are one of the absolute fundamentals of programming. I'm here to help people with problems, not teach them how to program from scratch. If you need to learn the basics then I suggest that you follow the Tutorial link in my signature below. It will teach you about loops and other fundamentals. If you have some grasp of loops already but want more examples then I'm quite sure that you can find plenty of examples on the web.
 
Back
Top Bottom