asp classic Split data and transfer it to another table ...

Dear all Experts in ASP Classic

I am working with asp classic and msaccess db

I need a bit help for this script to be executed according my needs.

set conn=server.CreateObject("adodb.connection") "Provider=Microsoft.jet.oledb.4.0;data source="& server.MapPath("db\bd1.mdb")
set rs_main=server.CreateObject("adodb.recordset") "select fileid,title,texts from add0",conn,1,2

do while not rs_main.eof
	dim p
    for x=1 to len(d)
    if mid(d,x,1)="," or mid(d,x,1)="." or mid(d,x,1)="!" then
    conn.execute("insert into table2 values ("&rs_main("fileid")&",'"&title&"','"&texts&"')")
    end if
set rs_main=nothing

Open in new window


Table name = Add0
fileid (autonumerical)
title (text=100)
texts (Memo)

Table name = table2
fileid (autonumerical with  duplicates)
title (text = 100 with duplicates)
texts (text = 100 with duplicates)


The script splits a long memo field into substrings splitted by "." or "," or "!", but not works adequately because sometimes a substring are larger than the width of the table2.texts

Do you know a way to change this script to split (1) the substrings in 10 words or (2) length (=100) avoiding to cut words or (3) each capital letter?

I would be grateful for any help..
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertConsultingCommented:
Maybe with a simple regex, and return the results as an array:
Public Function split10Words(ByVal data As String) As String()
    Dim rx As Object
    Dim matches As Object
    Dim ret() As String
    Dim i As Long
    ReDim ret(0 To 0)
    Set rx = CreateObject("VBScript.Regexp")
    rx.Pattern = "(\S+)"
    rx.Global = True
    Set matches = rx.Execute(data)
    For i = 0 To matches.count - 1
        ret(UBound(ret)) = ret(UBound(ret)) & matches(i) & " "
        If ((i + 1) Mod 10) = 0 Then
            ReDim Preserve ret(0 To UBound(ret) + 1)
        End If
    set matches = Nothing
    Set rx = Nothing
    split10Words = ret
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BOB KUSPEAuthor Commented:
Many Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.