What is the split() equivalent in Access '97?

dougmcc1

Registered User.
Local time
Today, 11:20
Joined
Jul 29, 2004
Messages
27
Hi,

I need to split a string into an array by the space character but I'm working in Access '97 which doesn't feature a split() function. Does anyone know the equivalent?

Thanks.
 
Doug -

Give this a try.
Code:
Function ySplit(ByVal pTarget As String, _
                pItem As String, _
                Optional ShowLeft As Boolean = True) _
                As String
'*******************************************
'Purpose:    Splits a string to the left or
'            right of pItem
'Coded by:   raskew
'Inputs:     1)  ? ySplit("The quick+ brown fox", "+", True)
'            2)  ? ysplit("The quick+ brown fox", "+", False)
'Output:     1)  The quick
'            2)  brown fox
'*******************************************

Dim strLeft  As String
Dim strRight As String
Dim n        As Integer

    n = InStr(pTarget, pItem)
    
    If n = 0 Then
       ySplit = pTarget
    Else
       ShowLeft = IIf(IsMissing(ShowLeft), True, ShowLeft)
       strLeft = Trim(Left(pTarget, n - 1))
       strRight = Trim(Mid(pTarget, n + 1))
       ySplit = IIf(ShowLeft, strLeft, strRight)
    End If
    
End Function
HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom