Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: Bazooka en Diciembre 16, 2014, 07:05:36 pm
-
Hola mis amigos estuve un poco alejado pero no muerto!.
Estoy un poco desorientado con esto asi que por favor acudo a uds.
Necesito por favor me ayuden a crear una función robusta para validar datos contenidos en un array, ahi va la explicacion.
Tengo grupos de combinaciones de la siguiente manera :
Private Sub Form_Load()
COMBINA(1) = "02 07 08 19 31 02 35 51 54 59 64 68 76 82 87"
COMBINA(2) = "02 05 08 31 32 33 35 39 51 54 59 64 76 82 87"
COMBINA(3) = "18 25 29 33 34 38 41 47 51 59 63 71 77 85 90"
COMBINA(4) = "07 19 33 34 38 47 51 52 54 56 59 66 68 76 87"
COMBINA(5) = "07 19 29 34 38 41 47 52 54 56 66 68 76 87 90"
End Sub
'VALIDACION 1
Y necesito validar que cada combinación del grupo no tenga números repetidos dentro de cada una de ellas
'########################################################################
' VERIFICAR QUE NO HAYA NUMEROS REPETIDOS EN UNA MISMA COMBINACION NUMER.
'########################################################################
Function VerificarNumerosIgualesEnCombinacion() As Boolean
Dim MAT() As String
MAT() = Split(COMBINA(1), " ")
For n = 0 To UBound(MAT())
Next
VerificarNumerosIguales = False
End Function
VALIDACION 2
Esta me funciona correcta solo la pongo para que la vean como es y si tal vez se pudiera simplificar seria barbaro
'0000000000000000000000000000000000000000000000000000000000000000000000000000
'0 VERIFICA QUE LOS ARRAYS TENGAN LA MISMA CANTIDAD DE DIGITOS ENTRE SI 0
'0000000000000000000000000000000000000000000000000000000000000000000000000000
Function VerificarDuplicados() As Boolean
Dim i
For i = 1 To 4
If i = 1 Then 'para no chequerase a si mismo
'''''''
If COMBINA(2) <> "" Then
If Len(COMBINA(1)) <> Len(COMBINA(2)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 2"
Exit Function
End If
End If
'#########################################################
If COMBINA(3) <> "" Then
If Len(COMBINA(1)) <> Len(COMBINA(3)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 3"
Exit Function
End If
End If
'#########################################################
If COMBINA(4) <> "" Then
If Len(COMBINA(1)) <> Len(COMBINA(4)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 4"
Exit Function
End If
End If
'#########################################################
If COMBINA(5) <> "" Then
If Len(COMBINA(1)) <> Len(COMBINA(5)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 5"
Exit Function
End If
End If
End If
'#####################################################################
'////////////////////////////////////////////////////////////////////
'#####################################################################
If i = 2 Then 'para no chequerase a si mismo
If COMBINA(3) <> "" Then
If Len(COMBINA(2)) <> Len(COMBINA(3)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 3"
Exit Function
End If
End If
'#########################################################
If COMBINA(4) <> "" Then
If Len(COMBINA(2)) <> Len(COMBINA(4)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 4"
Exit Function
End If
End If
'#########################################################
If COMBINA(5) <> "" Then
If Len(COMBINA(2)) <> Len(COMBINA(5)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 5"
Exit Function
End If
End If
End If
'#####################################################################
'////////////////////////////////////////////////////////////////////
'#####################################################################
If i = 3 Then 'para no chequerase a si mismo
If COMBINA(4) <> "" Then
If Len(COMBINA(3)) <> Len(COMBINA(4)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 4"
Exit Function
End If
End If
'#########################################################
If COMBINA(5) <> "" Then
If Len(COMBINA(3)) <> Len(COMBINA(5)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 5"
Exit Function
End If
End If
End If
'#####################################################################
'////////////////////////////////////////////////////////////////////
'#####################################################################
If i = 4 Then 'para no chequerase a si mismo
If COMBINA(5) <> "" Then
If Len(COMBINA(4)) <> Len(COMBINA(5)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays 1 y 5"
Exit Function
End If
End If
End If
Next
VerificarDuplicados = True
Label2.Visible = True
End Function
-
Hola Miguel haber si es así
Private Function VerificarDuplicados() As Boolean
Dim i As Long, j As Long
For i = 1 To 4
For j = i + 1 To 5
If Len(COMBINA(i)) <> Len(COMBINA(j)) Then
MsgBox "Existen diferentes cantidades de numeros en los arrays " & i & " y " & j
Exit Function
End If
Next
Next
VerificarDuplicados = True
End Function
Function VerificarNumerosIgualesEnCombinacion() As Boolean
Dim MAT() As String
Dim n As Long, i As Long, j As Long
For n = 1 To 5
MAT() = Split(COMBINA(n), " ")
For i = 0 To UBound(MAT())
For j = i + 1 To UBound(MAT())
If MAT(i) = MAT(j) Then
MsgBox "En el grupo de combinación " & n & " el numero " & MAT(i) & " se encuentra repetido en la posicion " & i + 1 & " y " & j + 1
Exit Function
End If
Next
Next
Next
VerificarNumerosIguales = False
End Function
Saludos.
-
GENIAL LEANDRO MUCHISIMAS GRACIAS ANDUVO PERFECTO !!!!
ABRAZOS