Visual Basic Foro

Programación => Visual Basic 6 => Mensaje iniciado por: 79137913 en Junio 11, 2012, 11:48:03 am

Título: [FUNCION] EntreTextos Busca string entre otras 2
Publicado por: 79137913 en Junio 11, 2012, 11:48:03 am
HOLA!!!

La encontre en un proyecto que estoy desarrollando y por ahi le sirve a alguien.

Busca un string entre otros 2 strings.

Por ejemplo :

Código: (vb) [Seleccionar]
Private Sub Form_Load()
    str1 = "hola franco como andas, hola pepe como andas"
    str2 = "hola "
    str3 = " como"
    Debug.Print EntreTextos(str1, str2, str3)
    'imprimira: "franco"
    'como veran solo la primera asi que ojo XD
End Sub

Public Function EntreTextos(Text As String, Text1 As String, Text2 As String) As String
    EntreTextos = MidB$(Text, InStrB(Text, Text1) + LenB(Text1), InStrB(Text, Text2) - InStrB(Text, Text1) - LenB(Text1))
End Function

GRACIAS POR LEER!!!