Results 1 to 6 of 6

Thread: [RESOLVED] get pieces of string

  1. #1

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Resolved [RESOLVED] get pieces of string

    with vb6 + access

    how can i extract the portion of a string separated by a "-"
    symbol
    like i want to
    INSERT the each piece of string in to a table
    for eg: from string "axb-bh-c22-dtr-egt-f" into a table

    axb
    bh
    c22
    dtr
    egt
    f

  2. #2
    Hyperactive Member Lenggries's Avatar
    Join Date
    Sep 2009
    Posts
    353

    Re: get pieces of string

    arrStrings = Split("axb-bh-c22-dtr-egt-f","-")

  3. #3

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Question Re: get pieces of string

    some more in detail please

  4. #4
    Hyperactive Member Lenggries's Avatar
    Join Date
    Sep 2009
    Posts
    353

    Re: get pieces of string

    You don't give me much to work with, but I'll give it a shot:
    Code:
    Dim i As Long
    Dim arrStrings() As String
    Dim strSQL as String
    
    arrStrings = Split("axb-bh-c22-dtr-egt-f","-") 
    
    For i = 0 To Len(arrStrings)
       strSQL = "INSERT INTO table_name (column_name) VALUES ('" & arrStrings(i) & ",)"
       myDatabaseConnection.Execute(strSQL)
    Next i
    Basically just split your string by the delimiter, then iterate through the resulting array and insert each item into your database table.

  5. #5

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Question Re: get pieces of string

    thanks a lot
    if delimiter is of multiple type like space or > then
    is there any other function to evaluate it

  6. #6

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Wink Re: get pieces of string

    thanks i used the replace function to make all unique

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width