emulates VB6s Split() function for VB5 (and possibly lower)
emulates VB6s Split() function for VB5 (and possibly lower)
Rate emulates VB6s Split() function for VB5 (and possibly lower)
(2(2 Vote))
'| Purpose: to emulate VB6s Split() function
'| Author: xetlain/Lee Turner
'| Contact: [email protected]
'`------------------=(26/06/2002)=-------
Public Function Split(ByVal SplitString As String, SearchString As String, ByRef SplitArray() As String, index As Integer) As Integer
Dim lstr As String
Split = 0 'return 0 if the SearchString was not found
Do
If InStr(SplitString, SearchString) <> 0 Then
Split = 1 'we have found the SearchString and we can now split it into an array, return 1
lstr = Left$(SplitString, InStr(SplitString, SearchString) - 1)
SplitString = Mid$(SplitString, InStr(SplitString, SearchString) + Len(SearchString))
ReDim Preserve SplitArray(index) As String
SplitArray(index) = lstr
index = index + 1
Else
Exit Do
End If
Loop
index = index - 1 'tbh, I'm not sure why this is here, but it seems to make things work, I'm too tired to argue with it
End Function
'.-----------------------------------------
'| There are still bugs in this, I'm lazy.
'| below is a quick example on how to call
'| the above code (note no error checking)
'|
'| Dim myarray() As String
'| Dim index As Integer
'| Dim retval As String
'| retval = Split("0" & vbCrLf & "1" & vbCrLf & "2" & vbCrLf, vbCrLf, myarray(), index)
'| Dim x As Integer
'| For x = 0 To index
'| Debug.print "myarray(" & x & ") Contains: " & myarray(x)
'| Next x
'|
'| Hope this is useful!
'`------------------------
emulates VB6s Split() function for VB5 (and possibly lower) Comments
No comments yet — be the first to post one!
Post a Comment