Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cut a sentence in words

Status
Not open for further replies.

FROGGY01

Technical User
Aug 9, 2002
6
FR
hi everyone
so this my problem i want to cut in sentence in word:
the sentence is in a first table with a code like :

table_sentences
sentence : " the dog run in the garden "
code : 01
(sorry for the sentence, next time i will make better)

and i want this result in table_word
words|code|
------|----|
the |01 |
dog |01 |
run |01 |
in |01 |
the |01 |
garden|01 |

thanks
 
hello

you should use the split function :

Option Explicit

Private Sub Command1_Click()
Dim strTest As String
Dim strArray() As String
Dim intCount As Integer

strTest = "Fred & Wilma & Barney & Betty"
strArray = Split(strTest, "&")

For intCount = LBound(strArray) To UBound(strArray)
Debug.Print Trim(strArray(intCount))
Next
End Sub

you can adapt this function by replacing the delimiter character and in the loop, you should assign each value to the field
 
dear p27br
split doesnt work with access
so i use
Function s_Coupemot(ByVal strOu As String, rs_sep As String) As String


Dim ls_Result As String
Dim li_Pos As Integer
Dim ls_word As String


ls_Result = ""
ls_word = ""
While Len(strOu) > 0
li_Pos = InStr(strOu, rs_sep)
If li_Pos = 1 Then
ls_Result = ls_Result + Left$(strOu, 80)
strOu = Mid$(strOu, li_Pos + Len(rs_sep))
Else
ls_word = Left$(strOu, li_Pos - 1)
ls_Result = ""

Debug.Print ls_word

strOu = Mid(strOu, li_Pos, 80)

s_Coupemot = ls_word

End If



Wend

End Function

the problem is know how to integrate the result in a new table
 
what version of access do you have ?
There are several similar procedures on this website which do the same for Access97 try a search on split or bassplit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top