Solved

Finding words from within text

Posted on 1998-12-11
3
148 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 20 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now