3
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by Bob Jacobs
0

Get lenght of sentence by len(string), use for i = 1 to lenght of sentence with mid(sentence i 1) to get characters and combine words after characters isn't space or punctuation.

0

hi.. i would like to save every word in the sentence separating by space " "...


any idea on it??

thxx

this is one way

'set up an array to contain the words
Dim words(1 To 100) As String

'get the length of the sentence
sentencelength = Len(sentence)

'set a counter for the number of words
flag = 1

'a do loop to find the words
Do Until sentencelength = 0
'find the first space in the sentence
firstspace = InStr(sentence, " ")
'record the first word
words(flag) = Left(sentence, firstspace - 1)
'increment the word counter
flag = flag + 1
' knock the first word (and space) off sentence
sentence = Mid(sentence, firstspace + 1)
'get the new sentence length
sentencelength = Len(sentence)
Loop

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.