Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Finding words from within text

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

789 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