|
-
Jul 10th, 2007, 07:55 AM
#1
Thread Starter
Junior Member
[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
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
-
Jul 10th, 2007, 07:59 AM
#2
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."
-
Jul 10th, 2007, 08:01 AM
#3
Re: php explode() equivalent in VB?
And the mirror of Split() is Join().
-
Jul 10th, 2007, 09:19 AM
#4
Thread Starter
Junior Member
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
-
Jul 10th, 2007, 09:32 AM
#5
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
-
Jul 10th, 2007, 09:38 AM
#6
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.
-
Jul 10th, 2007, 09:44 AM
#7
Thread Starter
Junior Member
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
-
Jul 10th, 2007, 09:53 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|