About This Code
Brief Description:
Split string
Contributor:
Dmitry Akulov
Notes Version:
R5.x, R6.x
Last Modified:
08 Oct 2003
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Private Function SplitString(Byval src As String,Byval delimiter As String) As Variant
Dim i As Integer
Dim l As Integer
Dim retarr() As String
i=Instr(src,delimiter)
l=Len(delimiter)
If i>0 And l>0 Then
SplitString=Arrayappend(SplitString(Left(src,i-1),delimiter),SplitString(Mid(src,i+l),delimiter))
Else
SplitString=GetArray(src)
End If
End Function
' Make Array from any
Private Function GetArray(src As Variant) As Variant
Dim tmparr()
If Isarray(src) Then
GetArray=src
Else
Redim tmparr(0 To 0)
If Isobject(src) Then
Set tmparr(0)=src
Else
tmparr(0)=src
End If
GetArray=tmparr
End If
End Function
Usage / Example