Si tienen algun problema me avisan... para llamarlas les dejo 2 ejemplos.
Ejemplo : 1
ACM1PT = SplitA01(expression, "tiramelagoma")
Ejemplo : 2
Dim Peteras() as String
Call SplitB(expression, Peteras(), "billeteramatagalan")
Código: Seleccionar todo
' by Donald, [email protected], 20000916
Public Function SplitA01(Expression As String, _
Optional Delimiter As String = " ", _
Optional Count As Long = -1, _
Optional Compare As VbCompareMethod = vbBinaryCompare) As Variant
Const BUFFERDIM As Long = 1024
Dim cntSplit As Long
Dim posStart As Long
Dim posFound As Long
Dim lenDelimiter As Long
Dim sArray() As String
Dim ubArray As Long
If Count = 0 Then
' return unbound Variant array
SplitA01 = Array()
Exit Function
End If
lenDelimiter = Len(Delimiter)
If lenDelimiter = 0 Then
' return expression in single-element Variant array
SplitA01 = Array(Expression)
Else
posStart = 1
ubArray = -1
Do
If cntSplit > ubArray Then
ubArray = ubArray + BUFFERDIM
ReDim Preserve sArray(ubArray)
End If
posFound = InStr(posStart, Expression, Delimiter, Compare)
If cntSplit + 1 = Count Then
sArray(cntSplit) = Mid$(Expression, posStart)
Exit Do
Else
If posFound Then
sArray(cntSplit) = Mid$(Expression, posStart, posFound - posStart)
posStart = posFound + lenDelimiter
cntSplit = cntSplit + 1
Else
sArray(cntSplit) = Mid$(Expression, posStart)
End If
End If
Loop While posFound
' shrink to actual size
ReDim Preserve sArray(cntSplit)
' return string array as Variant array
SplitA01 = sArray
End If
End Function
Código: Seleccionar todo
Public Sub SplitB01(Expression As String, _
sArrRet() As String, _
Optional Delimiter As String = " ")
' by Donald, [email protected], 20000916
Const BUFFERDIM As Long = 1024
Dim cntSplit As Long
Dim posStart As Long
Dim posFound As Long
Dim lenDelimiter As Long
Dim ubArray As Long
lenDelimiter = Len(Delimiter)
If lenDelimiter = 0 Then
' return expression in single-element array
ReDim Preserve sArrRet(0)
sArrRet(0) = Expression
Else
posStart = 1
ubArray = -1
Do
If cntSplit > ubArray Then
ubArray = ubArray + BUFFERDIM
ReDim Preserve sArrRet(ubArray)
End If
posFound = InStr(posStart, Expression, Delimiter)
If posFound Then
sArrRet(cntSplit) = Mid$(Expression, posStart, posFound - posStart)
posStart = posFound + lenDelimiter
cntSplit = cntSplit + 1
Else
sArrRet(cntSplit) = Mid$(Expression, posStart)
End If
Loop While posFound
' shrink to actual size
ReDim Preserve sArrRet(cntSplit)
End If
End Function
Código: Seleccionar todo
Public Sub SplitB03(Expression$, ResultSplit$(), Optional Delimiter$ = " ")
' by G.Beckmann, [email protected]
Dim c&, iLen&, iLast&, iCur&
iLen = Len(Delimiter)
If iLen Then
'/ count delimiters
iCur = InStr(Expression, Delimiter)
Do While iCur
iCur = InStr(iCur + iLen, Expression, Delimiter)
c = c + 1
Loop
'/ initalization
ReDim Preserve ResultSplit(0 To c)
c = 0: iLast = 1
'/ search again...
iCur = InStr(Expression, Delimiter)
Do While iCur
ResultSplit(c) = Mid$(Expression, iLast, iCur - iLast)
iLast = iCur + iLen
iCur = InStr(iLast, Expression, Delimiter)
c = c + 1
Loop
ResultSplit(c) = Mid$(Expression, iLast)
Else
ReDim Preserve ResultSplit(0 To 0)
ResultSplit(0) = Expression
End If
End Function