Hola es que estoy a cuenta de reloj :cry: tengo de entregar un sudoku el lunes y queria saber si alguien tiene algun sudoku que vaya bien para que si pudierais enviar ya que estoy cansado de ir de foro en foero durante dos meses poniendo dudas y tengo ganas de aprobar el curso y la unica manera es entregar este cansado sudoku 9x9 y si me pudieseis enviar algun sudoku que os vaya vien y no tengas que utilizar seria una gran ayuda es que tengo el mismo que estoy haciendo desde dos meses y no hay manera de acabarlo y como lo tengo de entregar el lunes para aprovar el curso queria perdiros este GRAN FAVORR mi hotmail es este ([email protected]) ya se que direis joder que cabroncete este, pero esque me estoy jugando el curso :cry: y queria saver si alguien me podria enviar un sudoku para que yo pueda ayudarme con el mio que ya esta casi acabado aqui hos dejo mi codigo haver si me podeis ayudar con el codigo . ayudarme porfa :(
Option Explicit
Const Gris As Long = &HE0E0E0
Const Blanco As Long = &HFFFFFF
----------------------------------------------------------
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