VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a REAL STRING PARSER. split string with more than one split character

by GoldStar (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 19th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is a REAL STRING PARSER. split string with more than one split character

API Declarations


Dim Data() As String
'For Module usage:
'Public Data() As String

Rate This is a REAL STRING PARSER. split string with more than one split character



'decode("test,test3,testttt",",")
'msgbox data(0) = "test"      -True
'msgbox data(1) = "teset3"    -True
'msgbox data(2) = "testttt"   -True
''''''''''''''''''''''''''''''''''''''''''''
Sub decode(ByVal inpt As String, ByVal splitChar As String)
    If Right(inpt, 1) <> splitChar Then 'If there isn't a splitChar at end of
        inpt = inpt & splitChar 'string then Add ONE
    End If
    For i = 1 To InStrRev(inpt, splitChar) 'Calculate the number of splitChar's
        If Mid(inpt, i, 1) = splitChar Then 'so we can reDim Data()
            z = z + 1
        End If
    Next i
    ReDim Data(z - 1)
    For i = 1 To Len(inpt) 'Start splitting temporary string into the real
        crntchr = Mid(inpt, i, 1) 'Data() string array
        If crntchr <> splitChar Then
            temp = temp & crntchr 'Yeah its only one byte at a time, its still
        ElseIf crntchr = splitChar Then 'usefull
            x = x + 1
            Data(x - 1) = temp 'x-1 so we dont waste any space
            temp = "" 'Clear temporary string
        End If
    Next i 'and reiterate
End Sub

Download this snippet    Add to My Saved Code

This is a REAL STRING PARSER. split string with more than one split character Comments

No comments have been posted about This is a REAL STRING PARSER. split string with more than one split character. Why not be the first to post a comment about This is a REAL STRING PARSER. split string with more than one split character.

Post your comment

Subject:
Message:
0/1000 characters