Solved

Finding words from within text

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 102
VBA filters 2 59
Recommendation vb6 to vb.net or others 14 148
MS Access 03, TransferText, decimal places 8 69
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

770 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