Attribute VB_Name = "VB6Compatibility"
Public Function Split(sWords As String, sDelim As String) As Variant
Dim sTemp As String
Dim vWords() As Variant
Dim n, nCount As Integer
    nCount = 0
    sTemp = sWords
    Do
        n = InStr(1, sTemp, sDelim)
        ReDim Preserve vWords(nCount)
        If n = 0 Then
            vWords(nCount) = sTemp
        Else
            vWords(nCount) = left$(sTemp, n)
            If Right(vWords(nCount), 1) = sDelim Then
                vWords(nCount) = Mid(vWords(nCount), 1, _
                Len(vWords(nCount)) - 1)
            End If
            sTemp = Mid$(sTemp, n + 1)
        End If
        nCount = nCount + 1
    Loop Until n = 0
    Split = vWords
End Function

Public Function Replace(ByVal Expression As String, ByVal FindString As String, ByVal ReplaceString As String, _
                        Optional ByVal Start As Long = 1, Optional ByVal ReplaceCount As Long = -1, _
                        Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As String
'===============================================================================
'   Replace - This function mimics the VBA6.Replace function which is not
'   available in VB5. This function helps VB5 & VB6 projects co-exist.
'
'   NOTE: Note, anyone making adjustments to this function should keep in
'   mind that it is intended to behave EXACTLY like the VBA6.Replace
'   function (flaws and all, including operands).
'
'   Expression      String to be searched.
'   FindString      String being sought.
'   ReplaceString   Replacement substring.
'   Start           Optional. Position within expression where substring
'                   search is to begin. If omitted, 1 is assumed.
'   ReplaceCount    Optional. Number of substring substitutions to perform.
'                   If omitted, the default value is –1, which means make
'                   all possible substitutions.
'   Compare         Optional. Numeric value indicating the kind of comparison
'                   to use when evaluating substrings. See Settings section
'                   for values.
'===============================================================================
Dim FindLen     As Long     ' length of search string
Dim Pos         As Long     ' position where search string located
Dim nCount      As Long     ' # of replacements
    
    On Error GoTo ErrHandler                            ' trap all errors
    
    FindLen = Len(FindString)                           ' ID length of search string
  
    Pos = 1                                             ' initialize the loop
    Do While Pos > 0
        Pos = InStr(Pos, Expression, FindString)        ' locate search string
        'Found, Is the string being replaced the same length as the search string
        'If not I must divide the string at the search string position
        If Pos > 0 Then                                 ' substring found
            nCount = nCount + 1
            Expression = left$(Expression, Pos - 1) & _
                ReplaceString & _
                Mid$(Expression, Pos + FindLen)         ' make the replacement
        End If
        If nCount = ReplaceCount Then Exit Do           ' exit loop if max replacements reached
    Loop
    

ExitLabel:
    ' Return the result
    Replace = Expression
Exit Function
Resume
ErrHandler:
    Debug.Print Err.Description: Debug.Assert 0
    Resume ExitLabel
  
End Function
