Link to home
Start Free TrialLog in
Avatar of The_Oracle
The_Oracle

asked on

Accessing parts of text in text boxes (70pts)

How can I read a specific word of a certain line in a text box? If I have a box containing lots of words, I want to be able to get a certain word and read it by referring to some kind of address, e.g.

If I had a box containing the sentence "The cat sat on the mat.", how could I ask the program to return, say, word 3?
Avatar of lankford
lankford

As long as you are using a vb text box, you are probably going to have to parse the text and figure it out your self.

If you are programmatically using Microsoft Word as your text box, then you can actually refer to the third word in the Word object with something like this:

   ThirdWord = Document.Word(3)

Does anyone out there know of a text box ocx control that stores its information in easily accessible objects like this?

Lankford

Yep, you would have to check all text, but you could write a function who would create a kind of index of words. something what would keep the position of the word and it's lenth
then with the index you could get your word

"this is my string and i want to find a word in it"

for the word "my" you would keep the position (9) and the lenth (2) . and you could read your index to know where the words are. would be longer whe you create your index, but faster when you search your word...
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial