by Jacob Steenhagen (3 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 17th August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Performs a function similar to "split" in Perl
API Declarations
' array [Params()], but it can be used for many other applications.
Dim Params() As String
Dim Temp As String
Dim i, NumParams As Integer
'This allows the original string to remain in tact
Temp = Command 'Where Command is the string you want to break up
NumParams = 0
Do
' Replace " " with the character to split on (for CSV, it would be ",")
i = InStr(1, Temp, " ")
ReDim Preserve Params(NumParams)
If i Then
Params(NumParams) = Left(Temp, i - 1)
Temp = Right(Temp, Len(Temp) - i)
NumParams = NumParams + 1
Else
Params(NumParams) = Temp
End If
Loop While i
' NumParams in now the number of parameters in you're array.