string manipulation

Reply

Join Date: Jul 2007
Posts: 114
Reputation: jaasaria is an unknown quantity at this point 
Solved Threads: 1
jaasaria's Avatar
jaasaria jaasaria is offline Offline
Junior Poster

string manipulation

 
0
  #1
Nov 10th, 2008
hi.. i would like to save every word in the sentence separating by space " "...


any idea on it??

thxx
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 36
Reputation: Teropod is an unknown quantity at this point 
Solved Threads: 6
Teropod Teropod is offline Offline
Light Poster

Re: string manipulation

 
0
  #2
Nov 10th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 26
Reputation: Bob Jacobs is an unknown quantity at this point 
Solved Threads: 0
Bob Jacobs Bob Jacobs is offline Offline
Light Poster

Re: string manipulation

 
0
  #3
Nov 10th, 2008
Originally Posted by jaasaria View Post
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
Last edited by Bob Jacobs; Nov 10th, 2008 at 6:59 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 750 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC