|
-
Nov 3rd, 2000, 08:10 PM
#1
Thread Starter
Lively Member
how would i be able to parse a string like this:
373 3 3 113 "hello there" "sup all" 4 4
into this:
373
3
3
113
hello there
sup all
4
4
-
Nov 3rd, 2000, 08:21 PM
#2
Hyperactive Member
Well if you have VB6 you can use the Split function with a " " as delimiter. If you have VB5, no such command.
But, tada, I have a VB5 Split function for you!
Code:
Public Function WordSplit(sWords As String, sDelim As String) As Variant
Dim sTemp As String
Dim vWords() As Variant
Dim n, nCount As Integer
nCount = 0
sTemp = sWords
Do
n = InStr(1, sTemp, sDelim)
ReDim Preserve vWords(nCount)
If n = 0 Then
vWords(nCount) = sTemp
Else
vWords(nCount) = Left$(sTemp, n)
If Right(vWords(nCount), 1) = sDelim Then
vWords(nCount) = Mid(vWords(nCount), 1, Len(vWords(nCount)) - 1)
End If
sTemp = Mid$(sTemp, n + 1)
End If
nCount = nCount + 1
Loop Until n = 0
WordSplit = vWords
End Function
The code above was not written by me Alas, I do not know who the author was.
-
Nov 3rd, 2000, 08:25 PM
#3
Fanatic Member
Try this:
VB6 ONLY!!! (otherwise, maybe someone will post the split code for vb5)
Code:
Sub SplitIt(MyStr As String)
Dim Splited
Splited = Split(MyStr, " ")
For i = LBound(Splited) To UBound(Splited)
Debug.Print TrimQuotes(Splited(i))
End If
End Sub
Function TrimQuotes(String1 As String) As String
Dim FirstChr As String
Dim LastChr As String
FirstChr = Left(String1, 1)
LastChr = Right(String1, 1)
If FirstChr = Chr(34) And LastChr = Chr(34) Then
TrimQuotes = Mid(String1, 2, Len(String1) - 1)
Else
TrimQutoes = String1
End If
End Sub
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Nov 3rd, 2000, 08:26 PM
#4
Fanatic Member
I See someone did post the VB5 Split Function!!! Before Me!!!
(I haven't tested my trim quotes function, but it should work)
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Nov 4th, 2000, 03:25 AM
#5
Thread Starter
Lively Member
naa, thats not gonna work...
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
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
|