VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



emulates VB6s Split() function for VB5 (and possibly lower)

by xetlain (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 25th June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

emulates VB6s Split() function for VB5 (and possibly lower)

Rate emulates VB6s Split() function for VB5 (and possibly lower)



'| 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!
'`------------------------

Download this snippet    Add to My Saved Code

emulates VB6s Split() function for VB5 (and possibly lower) Comments

No comments have been posted about emulates VB6s Split() function for VB5 (and possibly lower). Why not be the first to post a comment about emulates VB6s Split() function for VB5 (and possibly lower).

Post your comment

Subject:
Message:
0/1000 characters