Y a que se debe toda tu explicacion de lo q usas y q no? xD jeje gracias por la info!
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
Private Sub Form_Load()
Debug.Print kCompare("elfo", "elefante")
Debug.Print kCompare("ave", "zorro")
Debug.Print kCompare("hola", "")
Debug.Print kCompare("zero", "zerocool")
Debug.Print kCompare("feo", " ")
Debug.Print kCompare("frog", "frog")
Debug.Print kCompare("faso", "fasa")
Debug.Print kCompare("JOJO", "jojo")
End Sub
Option Explicit
Private Sub Form_Load()
Debug.Print CheckWord("elfo", "elefante")
Debug.Print CheckWord("ave", "zorro")
Debug.Print CheckWord("hola", "")
Debug.Print CheckWord("zero", "zerocool")
Debug.Print CheckWord("feo", " ")
Debug.Print CheckWord("frog", "frog")
Debug.Print CheckWord("faso", "fasa")
Debug.Print CheckWord("JOJO", "jojo")
End Sub
Function CheckWord(sFirst As String, sSecond As String) As Long
Dim i As Integer
Dim max As Integer
sFirst = LCase$(Trim$(sFirst))
sSecond = LCase$(Trim$(sSecond))
' Verificar error
If sFirst = "" Or sSecond = "" Then
CheckWord = 0: Exit Function
End If
' Establecer valor maximo del bucle
If Len(sFirst) < Len(sSecond) Then
max = Len(sFirst)
Else
max = Len(sSecond)
End If
'Bucle
For i = 1 To max
If (Left(sFirst, i) < Left(sSecond, i)) Then
CheckWord = 1
Exit Function
ElseIf (Left(sFirst, i) > Left(sSecond, i)) Then
CheckWord = 2
Exit Function
' Si por ahora es igual..
ElseIf (Left(sFirst, i) = Left(sSecond, i)) Then
If i = max Then ' Si ya termina el bucle comprobamos..
If Len(sFirst) > Len(sSecond) Then
CheckWord = 2
Exit Function
End If
If Len(sFirst) < Len(sSecond) Then
CheckWord = 1
Exit Function
End If
' Por descarte..
CheckWord = 3
Exit Function
End If
End If
Next i
End Function
2
1
0
1
1
3
2
3