Hi,
I'd suggest to split the words using the "Split" function and then look for
the first letter.
Here's the code:
--------
Option Explicit
Option Base 0
Private Sub Command1_Click()
Dim words() As String 'array of words
words = Split(txtMain.Text, " ") 'puts every word in the array
Dim i As Integer
For i = 0 To UBound(words) 'passes through the array
If Left(words(i), 1) = "t" Or Left(words(i), 1) = "d" Then
If Len(txtExtract.Text) = 0 Then 'adds the proper words into the
second textbox, delimiting them with spaces
txtExtract.Text = words(i)
Else
txtExtract.Text = txtExtract.Text & " " & words(i)
End If
End If
Next i
End Sub
--------
-- germol
"cassandra.flowers" <ca***************@btopenworld.com> a écrit dans le
message de news:bp**********@titan.btinternet.com...
Hi,
I am using VB6 and want to extract text from a string. But ONLY take out
words that begin with 't' or 'd'. The mainstring is input by the user
into 'txtMain' and then by clicking a command button, all the words that begin
with 't' or 'd' will be extracted and appear in a second text box,
txtExtract.
So, i know that I have to search through the main string for the character
"d", then extract the following characters until it reaches " " (the
space). I know I will have to use the Mid function to find it and the Len function
to get extract the whole word. The loop it to do the whole string. In
theory it works, but in practice I cant seem to get it to do what I want!
If for example, I type in "dog", the program extracts "d" into the text
box, not the whole word.
Can anyone give me some advice please?
Thanks
Cassandra