-
373 3 3 113 "hello there" "sup all" 4 4
i need to parse out the first 4 strings then parse out the words in ""s, but at the same time keeping there spacing, and then parse out the last 2 strings so that it comes out as:
373
3
3
113
hello there
sup all
4
4
-
How is the Information stored ? In a file or a String ? I'm going to assume it's in a string . I'm also going to assume your using VB6 . Try something like this .
Code:
Dim ParsedData( )
Dim Data as String
If Trim(Data) <> "" And InStr(1, Data, ":") Then
ParsedData = Split(Data, " ", -1)
You can Then Access the elements of the parsedData array like . This will return element 1 .
Code:
msgbox parsedData(0)
Hope that helped a little . I just woke up .
[]P
-
-
Scorpionz ,
I Don't think the split function is in VB5 , I Don't know another way to do it .
Sorry ,
[]P
-
Here's mysplit by Iain, it should work almost the same (you pass the array instead) as split except it's a lot faster for larger arrays :)
Code:
Private Sub Mysplit(Source, searchs As String, ByRef Arr() As String)
Dim pos As Long, pos2 As Long, x As Long
pos = 0
If Right(Source, Len(searchs)) = searchs Then
Source = Mid(Source, 1, Len(Source) - Len(searchs))
End If
Do
pos = InStr(pos + 1, Source, searchs, vbTextCompare)
If pos = 0 Then Exit Do
ReDim Preserve Arr(x)
Arr(x) = Mid(Source, pos + 1, pos + Len(searchs) - 2)
x = x + 1
Loop
End Sub
-
Change all that to Right$ instead of Right and Mid$ instead of Mid -- and Left$ instead if Left, for that matter.
Appending the $ suffix -- for some reason -- makes VB 5 apps perform better after compilation.
And, hey keda .. no offense
-
Well it's Iains, so it's np, but in Vb6, some of those just disappear
-
the $ thing is odd; is it that right$ etc are especially for strings, whereas right, etc take a variant?
-
grrrrrrrrrrrr
ok, none of this is working out properly... =\
-
Just use this code from Megatron, rearrange it around and you get:
Code:
Private Function RemoveText(ByVal Text As String) As String
'from Megatron
Dim i As Integer
Dim bInTag As Boolean
Dim strTmpStr As String
bInTag = False
For i = 1 To Len(Text)
If Not bInTag Then
If Mid(Text, i, 1) <> """" Then
strTmpStr = strTmpStr & Mid(Text, i, 1)
Else
bInTag = True
End If
Else
If Mid(Text, i, 1) = """" Then
bInTag = False
End If
End If
Next
RemoveText = strTmpStr
End Function
Private Sub Command1_Click()
Dim strString As String
strString = "373 3 3 113 ""hello there"" ""sup all"" 4 4"
MsgBox RemoveText(strString)
End Sub
-
about to give up =\
yes, that would work, but i would want the string to be added to a listbox as so:
373
3
3
113
hello there
sup all
4
4
-
Yeah, so after that, use the split kedaman suggested.