Página 1 de 1

[Función]Split 2 delimitadores [VB6]

Publicado: 25 Sep 2013, 01:26
por Himanen
Dejo la traducción de el split este que me curre hace un time en C#
Public Function sSplit(texto As String, del1 As String, del2 As String) As String

Dim p1 As Integer

Dim p2 As Integer

Dim tm As Integer

p1 = InStr(texto, del1)

p2 = InStr(texto, del2)

tm = p2 + Len(del2)

    If del2 <> "" Then
    
        sSplit = Mid(texto, p1 + Len(del1), tm - (p1 + Len(del1) + Len(del2)))
        
    Else
    
        sSplit = Mid(texto, p1 + Len(del1), Len(texto) - (p1 + Len(del1)))
        
    End If

End Function
Uso:
sSplit("HolaComoTeVa?", "Como","") =  "TeVa?"
sSplit("HolaComoTeVa?", "","Como")  =  "Hola"
sSplit("HolaComoTeVa?", "Hola","TeVa?") =  "Como"