Pretty_Girl
Pretty_Girl

Reputation: 157

Copy 5th word of the "rich text box1" to "textbox1.text"

The richtextbox1 contains 8 words "The brown fox jumped over the lazy dog". I want to copy the 5th word of the richtextbox1 to textbox1.text when the button1 clicked.

can this be done using find method such as find(character, start integer, end integer) etc ie. finding "empty" (space) character and read the characters until second "empty"(space) character found. or any other better method?

Upvotes: 1

Views: 65

Answers (2)

arsnlupn
arsnlupn

Reputation: 59

You may also use the Mid function indeed. Chech it out from https://msdn.microsoft.com/en-us/library/05e63829(v=vs.90).aspx

Updated

textbox1.text = Mid(richtexbox1.text, 1, 5)

Upvotes: 1

Pure
Pure

Reputation: 158

I would suggest using the split function for this scenario. e.g

textbox1.text = richtextbox1.text.split(" ")(4) 'This is for the 5th word.

Upvotes: 1

Related Questions