CISA FotoGallery

Statistiche

Tot. visite contenuti : 928206
Home Articoli tecnici Moduli Funzione SPLIT per A97

Funzione SPLIT per A97

'Alternativa alla Funzione SPILT di Access2000

Function fSplit(ByVal sIn As String, _
Optional sDelim As String, _
Optional nLimit As Long = -1, _
Optional bCompare As Long = vbBinaryCompare) _
As Variant

Dim sRead As String
Dim sOut() As String
Dim nC As Integer

If sDelim = "" Then
fSplit = sIn
End If

sRead = fReadUntil(sIn, sDelim, bCompare)

Do
ReDim Preserve sOut(nC)
sOut(nC) = sRead
nC = nC + 1
If nLimit <> -1 And nC >= nLimit Then
Exit Do
End If
sRead = fReadUntil(sIn, sDelim)
Loop While sRead <> ""
ReDim Preserve sOut(nC)
sOut(nC) = sIn
fSplit = sOut
End Function

Function fReadUntil(ByRef sIn As String, _
sDelim As String, _
Optional bCompare As Long = vbBinaryCompare) _
As String

Dim nPos As String
nPos = InStr(1, sIn, sDelim, bCompare)

If nPos > 0 Then
fReadUntil = Left(sIn, nPos - 1)
sIn = Mid(sIn, nPos + Len(sDelim))
End If
End Function