Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Mi Gran Ayuda Final Como Quitar Los Dos 10 Que Me Salen???? Urgente!!!

Estas en el tema de Mi Gran Ayuda Final Como Quitar Los Dos 10 Que Me Salen???? Urgente!!! en el foro de Visual Basic clásico en Foros del Web. Pues tengo una duda mañana tengo que entregar sin falta el sudoku y el problema es que cuando pulso el boton crear siempre me sale ...
  #1 (permalink)  
Antiguo 12/03/2007, 10:05
mfc
 
Fecha de Ingreso: febrero-2007
Mensajes: 33
Antigüedad: 17 años, 2 meses
Puntos: 0
Mi Gran Ayuda Final Como Quitar Los Dos 10 Que Me Salen???? Urgente!!!

Pues tengo una duda mañana tengo que entregar sin falta el sudoku y el problema es que cuando pulso el boton crear siempre me sale dos 10 aleatorio pero solo 2 y no se que hacer como quitarlos? alguien tiene un poquito de tiempo para ayudarme?

aqui teneis el codigo:
--------------------------------------------------------------------------
Private Sub cmdGenerar_Click()

CreateSudokuGrid

Dim i As Integer

For i = 1 To 81

Text1(i).Enabled = True
Text1(i).ForeColor = vbBlack
Text1(i).Enabled = False

Next i

End Sub
---------------------------------------------------------------------
Private Sub CreateSudokuGrid()

Dim b, i, j, k As Integer
Dim numRand As Integer
Dim ValIsOK(0 To 9) As Boolean
Dim valsOK As Integer

Do

For i = 1 To 81
Text1(i).Text = ""
Next i

For i = 1 To 81
If GetValidVals(i, ValIsOK()) = True Then
Randomize

Do
numRand = Int(10 * Rnd)
If ValIsOK(numRand) = True Then Exit Do
Loop

Text1(i) = numRand

Else

Text1(i) = "10"
End If
Next i
If isValid() Then Exit Do
Loop

For i = 1 To 81
Text1(i).Enabled = True
numRand = Rnd(CInt(3) + 1) + 1
If numRand > 1 Then

Text1(i).BackColor = Gris
Text1(i).ForeColor = vbBlack
Text1(i).Enabled = False
Else

Text1(i).BackColor = Blanco
Text1(i).ForeColor = Blanco

End If

Me.Refresh

Next i

End Sub
Private Function isValid()

Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim s(0 To 10) As Boolean

For i = 1 To 9
For j = 0 To 10: s(j) = False: Next j
For j = 1 To 9

k = (i - 1) * 9 + j
If s(Val(Me.Text1(k).Text)) = True Then
isValid = False: Exit Function
Else

s(Val(Me.Text1(k).Text)) = True

End If

Next j

Next i

For i = 1 To 9
For j = 0 To 10: s(j) = False: Next j
For j = 1 To 9

k = (j - 1) * 9 + i
If s(Val(Me.Text1(k).Text)) = True Then
isValid = False: Exit Function
Else

s(Val(Me.Text1(k).Text)) = True

End If

Next j

Next i

isValid = True

End Function
---------------------------------------------------------------------------------------
Private Function GetValidVals(ByVal Location As Integer, ByRef ValidVals() As Boolean) As Boolean

Dim i, j, k As Integer
Dim row, col As Integer
Dim numStr As String
Dim numOK As Boolean
Dim retVal As Boolean

For i = 1 To 9: ValidVals(i) = True: Next i

For i = 1 To 9

numStr = CStr(i)

For j = 1 To 9
k = (Int((Location - 1) / 9) * 9) + j
If Text1(k).Text = numStr Then ValidVals(i) = False
Next j

For j = 1 To 9
k = (((Location - 1) Mod 9) + 1) + ((j - 1) * 9)
If Text1(k).Text = numStr Then ValidVals(i) = False

Next j
Next i

retVal = False
For i = 1 To 9
retVal = IIf(ValidVals(i) = True, True, retVal)

Next i

GetValidVals = retVal

End Function
---------------------------------------------------------------------------------------
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:43.