Solved

Finding words from within text

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now