Module ArrayRoutines
    Sub ArrayParse(ByRef strArray() As String, ByVal strData As String, ByVal strDelim As String)

        On Error Resume Next

        Dim i As Short

        For i = (LBound(strArray)) To UBound(strArray) - 1
            strArray(i) = ArrayGet(strData, strDelim)
        Next

    End Sub
    Function ArrayGet(ByRef strData As String, ByVal strDelim As String) As String

        On Error Resume Next

        Dim intDelimPos As Short

        intDelimPos = strData.IndexOf(strDelim)
        If (intDelimPos = -1) Then
            ' what? no delimiters no data
            ArrayGet = strData.Trim
            strData = ""
        Else
            ' delimiters so strip it and return it
            ArrayGet = strData.Substring(0, intDelimPos)
            strData = strData.Substring(intDelimPos + 1, strData.Length - intDelimPos - 1)
        End If

    End Function
    Function ArrayCount(ByVal strData As String, ByVal strDelim As String) As Short

        On Error GoTo ErrorTrap

        Dim intDelimPos As Short
        Dim intCount As Short
        Dim intDelimNext As Short


        If strData = "" Then
            ' Number of elements = 0 if the source string is empty (this is a bad thing)
            ' carefull!!! here we're passing a 0 back which in error checking terms
            ' is acceptable but is really not
            ArrayCount = 0
        Else
            ' Otherwise number of tokens = number of delimiters + 1
            intDelimNext = strData.IndexOf(strDelim)
            Do Until intDelimPos = -1
                intCount = intCount + 1
                intDelimPos = strData.Substring(intDelimNext + 1, strData.Length - intDelimNext - 1).IndexOf(strDelim)
                intDelimNext = intDelimNext + 1 + intDelimPos
            Loop
            ArrayCount = intCount + 1
        End If

ErrorTrap:
        If Err.Number Then
            ArrayCount = ER_FATALERROR
            Exit Function
        End If

    End Function
End Module
