Funcion anterior "MEJORADA"
La sintaxis de la funcion es la suiguiente:
Verifica_Guion Texto, Caracter, Pos, Todo
Donde "Texto" es el texto que se quiere verificar, "Caracter" es el caracter (En este caso es un guion (-) ) que se deve encontrar en determinada posicion, "Pos" son las posiciones en las que deveria estar el caracter y "Todo" es una variable del tipo Boolean y sirve para indicar si el caracter tiene que aparecer en todas las posicones para que devulva "True" o si solo tiene que aparecer en una".
Las posiciones se escriben separadas por un punto y coma (;) es decir:
Matias=Verifica_Guion("-hola c-mo and-s", "-", "3;12;4;7;1", True)
...Esto va a verificar en las posiciones:
-----/-----
1
3
4
7
12
-----/-----
... y verifica que este en todas esas posiciones.
IMPORTANTE:
*NO INPORTA EL ORDEN DE LOS NUMEROS!!
*SI SE PRODUCE ALGUN ERROR EN LA FUNCION DEVUELVE "FALSE"
'FUNCION:
Private Function Verifica_Guion(Texto As String, Caracter As String, Pos As String, Todo As Boolean) As Boolean
On Error GoTo End1
Dim C1 As String
Dim C3() As String
If Len(Caracter) > 1 Then Verifica_Guion = False: Exit Function
C3 = Split(Pos, ";")
For i = 1 To UBound(C3)
DoEvents
If Trim(C3(i)) <> "" Then
C1 = Mid$(Texto, C3(i), 1)
If Todo = True Then
If C1 <> Caracter Then
Verifica_Guion = False
Exit Function
End If
Else
If C1 = Caracter Then
Verifica_Guion = True
Exit Function
End If
End If
End If
Next
Verifica_Guion = True
Exit Function
End1:
Verifica_Guion = False
End Function
'------------------------------------------------------********---------------------------------------
'-----------------------------------------********------------------********------------------------
'------------------------------------------------------********---------------------------------------
'EJEMPLO:
Private Sub Command1_Click()
If Verifica_Guion(Text1.text, "-", "3;12", True) = True Then
MsgBox "Bien"
Else
MsgBox "Mal"
End If
End Sub
POR MATIAS.
CHAU!!