Results 1 to 8 of 8

Thread: [RESOLVED] php explode() equivalent in VB?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    17

    Resolved [RESOLVED] php explode() equivalent in VB?

    Hey guys,

    I'm not sure how many of you are familiar with php (i'm sure quite a lot of you are)

    I was just wondering if VB had an equivalent explode function, currently im receiving some data delimited by the | character, like below

    data1|data2|data3|data4
    At the moment im trying to retrieve this data (done), then split this data up, and then enter it into array so i can do a for loop with some of the values.

    I'd really appreciate it if someone could point me to the solution.

    Thanks for your time,

    Adam

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: php explode() equivalent in VB?

    I think you are talking about the VB6 SPLIT Function
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: php explode() equivalent in VB?

    And the mirror of Split() is Join().

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    17

    Re: php explode() equivalent in VB?

    Ok, thanks, that worked great guys.

    But i want to change the goal posts now, the data is coming as this.

    First im splitting it using the | delimiter, but then i need to split it using the : delimeter

    data1:data2|data3:data4|data5:data6|data7:data8
    I need to perform some form of for loop to do that and split it again don't i? Well i've been trying that, can't seem to sort it - lol this is just basic stuff

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: php explode() equivalent in VB?

    Try something like
    Code:
    Private Sub Command1_Click()
    Dim sData1 As String
    Dim sData2 As String
    Dim arrData1() As String
    Dim arrData2() As String
    Dim i As Long
    sData1 = "data1:data2|data3:data4|data5:data6|data7:data8"
    arrData1 = Split(sData1, "|")
    sData2 = Join(arrData1)
    arrData2 = Split(sData2, ":")
    For i = 0 To UBound(arrData2)
        MsgBox arrData2(i)
    Next
    End Sub

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: php explode() equivalent in VB?

    You can also use Replace() to change the colons to pipes so you can split on one delimiter if this is what you need.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    17

    Re: php explode() equivalent in VB?

    Thanks for the help so far guys - its been "lightning" fast.


    Is their anyway of splitting the data in to two arrays

    data1:data2:|:data3:data4:|data5:data6:|:data7:data8
    For example, when i've split it down to this:

    data1:data2:data3:data4:data5:data6::data7:data8
    First array should include, 1, 3, 5, 7, and so on

    Second array, 2, 4, 6, 8 and so on

    The reason is because 1,3,5,7 include names and the other is a unique id

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: php explode() equivalent in VB?

    If your gonna use one delimiter then simply iterate Step 2. Iteration index goes to first array, index + 1 to the other.

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