Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Finding words from within text

Posted on 1998-12-11
3
Medium Priority
?
191 Views
Last Modified: 2010-05-03
Hi,
I would like to know if vb includes any function that can extract words from some text.
Like if i have text: Hello World
Function would know how to pick out first word (Hello) or second word (World). Or do i need to write my own function?

-hpet
0
Comment
Question by:hpet
  • 2
3 Comments
 

Accepted Solution

by:
budgie_b earned 60 total points
ID: 1449495
Use the find in the richtextbox control to search text for a whole word.  Here is some sample code.  Enter in a search string in Text1 to find in RichTextBox1.

Private Sub Form_Load()
Me.RichTextBox1.Text = "Hello World"
End Sub
Private Sub Command1_Click()
   Dim FoundPos As Integer
   Dim FoundLine As Integer
   ' Find the text specified in the TextBox control.
   FoundPos = RichTextBox1.Find(Text1.Text, , , rtfWholeWord)

   ' Show message based on whether the text was found or not.

   If FoundPos <> -1 Then
      ' Returns number of line containing found text.
      FoundLine = RichTextBox1.GetLineFromChar(FoundPos)
      MsgBox "Word found on line " & CStr(FoundLine)
   Else
      MsgBox "Word not found."

End If
End Sub

0
 
LVL 1

Author Comment

by:hpet
ID: 1449496
Thanks for answer. What if i don't have richtext box?
Treeview control has properties and one of them is for example .Text. Maybe I should set my question more precise before.
Not from text box, but from some string...
Any idea?
It isn't hard to write fuction that does it. It's just that i don't want to "reinvent the wheel".

-Peter

0
 
LVL 1

Author Comment

by:hpet
ID: 1449497
It was not what i really wanted though..
I did it my own way. I need to close this question up now..

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question