VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Performs a function similar to split in Perl

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.

Rate Performs a function similar to split in Perl




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.

Download this snippet    Add to My Saved Code

Performs a function similar to split in Perl Comments

No comments have been posted about Performs a function similar to split in Perl. Why not be the first to post a comment about Performs a function similar to split in Perl.

Post your comment

Subject:
Message:
0/1000 characters