Sudoku, juga dikenal sebagai Number Place atau Nanpure, adalah sejenis teka-teki logika. Tujuannya adalah untuk mengisikan angka-angka dari 1 sampai 9 ke dalam jaring-jaring 9x9 yang terdiri dari 9 kotak 3x3 tanpa ada angka yang berulang dari satu baris, kolom atau kotak. pertama kali diterbitkan di sebuah surat kabar Perancis pada 1895 dan mungkin dipengaruhi oleh matematikawan Swiss Leonhard Euler, yang membuat terkenal Latin Square.
Versi modern permainan ini dimulai di Indianapolis pada 1979. Kemudian menjadi terkenal kembali di Jepang pada 1986, ketika penerbit Nikoli menemukan teka-teki ini yang diciptakan Howard Garns.
nama "Sudoku" adalah singkatan bahasa Jepang dari "Suuji wa dokushin ni kagiru", artinya "angka-angkanya harus tetap tunggal".
Pembuatan game sudoku diatas adalah menggunakan software Visual Basic dengan tampilan :
form 1 :
script :
Private Sub Image2_Click()
MsgBox "Terima Kasih ^_^ Saran & Kritik ku terima dengan ikhlas"
End
End Sub
Private Sub imulai_Click()
Frame1.Top = 0
End Sub
Private Sub Label2_Click()
Form2.Show
Form1.Hide
End Sub
Private Sub Label3_Click()
Form3.Show
Form1.Hide
End Sub
Private Sub Label4_Click()
Form4.Show
Form1.Hide
End Sub
form 2 :
script :
Dim ss As Integer
Dim mm As Integer
Sub cekkolom1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 5
For j = i + 1 To 5
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(0).Picture = salah.Picture
Exit Sub
Else
ket(0).Picture = benar.Picture
End If
Next j
Next i
'------------------------
End Sub
Sub cekkolom2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 6 To 11
For j = i + 1 To 11
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(1).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(1).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 12 To 17
For j = i + 1 To 17
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(2).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(2).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 18 To 23
For j = i + 1 To 23
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(3).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(3).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 24 To 29
For j = i + 1 To 29
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(4).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(4).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 30 To 35
For j = i + 1 To 35
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(5).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(5).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 30 Step 6
For j = i + 6 To 30 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(6).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(6).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 1 To 31 Step 6
For j = i + 6 To 31 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(7).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(7).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 2 To 32 Step 6
For j = i + 6 To 32 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(8).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(8).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 3 To 33 Step 6
For j = i + 6 To 33 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(9).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(9).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 4 To 34 Step 6
For j = i + 6 To 34 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(10).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(10).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 5 To 35 Step 6
For j = i + 6 To 35 Step 6
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(11).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(11).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Private Sub Box_Change(Index As Integer)
cekkolom1
cekkolom2
cekkolom3
cekkolom4
cekkolom5
cekkolom6
cekbaris1
cekbaris2
cekbaris3
cekbaris4
cekbaris5
cekbaris6
ceksemua
End Sub
Sub ceksemua()
Dim i As Integer
Dim menang As Boolean
menang = True
For i = 0 To 11
If ket(i).Picture = salah.Picture Then
menang = False
Exit For
Exit Sub
End If
Next i
If menang = True Then
Call menang1
End If
End Sub
Private Sub Command1_Click()
For i = 0 To 35
box(i).Text = ""
box(0).Text = 3
box(1).Text = 6
box(2).Text = 4
box(3).Text = 5
box(4).Text = 2
box(5).Text = 1
box(6).BackColor = &H8000000A
box(7).BackColor = &H8000000A
box(8).Text = 5
box(9).Text = 4
box(10).Text = 3
box(11).Text = 6
box(12).Text = 4
box(13).Text = 5
box(14).Text = 2
box(15).Text = 6
box(16).Text = 1
box(17).BackColor = &H8000000A
box(18).Text = 6
box(19).BackColor = &H8000000A
box(20).Text = 3
box(21).Text = 2
box(22).Text = 5
box(23).Text = 4
box(24).Text = 2
box(25).Text = 3
box(26).BackColor = &H8000000A
box(27).BackColor = &H8000000A
box(28).Text = 4
box(29).BackColor = &H8000000A
box(30).Text = 5
box(31).Text = 4
box(32).Text = 1
box(33).Text = 3
box(34).BackColor = &H8000000A
box(35).Text = 2
Next i
tjam.Enabled = False
tjam.Enabled = True
ss = 0
mm = 0
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 11
ket(i).Picture = salah.Picture
Next i
For i = 0 To 35
Next i
End Sub
Sub menang1()
MsgBox "Selamat anda menang"
Form3.Show
End Sub
Private Sub lmulai_Click()
tframe.Enabled = True
End Sub
Private Sub lmulai_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lmulai.ForeColor = RGB(204, 153, 102)
End Sub
Private Sub Label2_Click()
MsgBox "Terima Kasih ^_^ Saran & Kritik ku terima dengan ikhlas"
End
End Sub
Private Sub tframe_Timer()
Frame1.Top = Frame1.Top - 10
If Frame1.Top = 120 Or Frame1.Top < 120 Then
tframe.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Dim k As Integer
For k = 0 To 35
box(k).ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next k
End Sub
Private Sub tjam_Timer()
ss = ss + 1
If ss = 60 Then
ss = 0
mm = mm + 1
End If
If Len(CStr(ss)) = 1 Then
sec = "0" & ss
Else
sec = ss
End If
If Len(CStr(mm)) = 1 Then
Min = "0" & mm
Else
Min = mm
End If
iwaktu.Caption = Min & ":" & sec
End Sub
form 3 :
script :
Dim ss As Integer
Dim mm As Integer
Sub cekkolom1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 8
For j = i + 1 To 8
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(0).Picture = salah.Picture
Exit Sub
Else
ket(0).Picture = benar.Picture
End If
Next j
Next i
'------------------------
End Sub
Sub cekkolom2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 9 To 17
For j = i + 1 To 17
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(1).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(1).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 18 To 26
For j = i + 1 To 26
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(2).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(2).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 27 To 35
For j = i + 1 To 35
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(3).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(3).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 36 To 44
For j = i + 1 To 44
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(4).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(4).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 45 To 53
For j = i + 1 To 53
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(5).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(5).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom7()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 54 To 62
For j = i + 1 To 62
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(6).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(6).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom8()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 63 To 71
For j = i + 1 To 71
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(7).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(7).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom9()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 72 To 80
For j = i + 1 To 80
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(8).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(8).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 72 Step 9
For j = i + 9 To 72 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(9).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(9).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 1 To 73 Step 9
For j = i + 9 To 73 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(10).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(10).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 2 To 74 Step 9
For j = i + 9 To 74 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(11).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(11).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 3 To 75 Step 9
For j = i + 9 To 75 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(12).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(12).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 4 To 76 Step 9
For j = i + 9 To 76 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(13).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(13).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 5 To 77 Step 9
For j = i + 9 To 77 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(14).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(14).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris7()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 6 To 78 Step 9
For j = i + 9 To 78 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(15).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(15).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris8()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 7 To 79 Step 9
For j = i + 9 To 79 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(16).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(16).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris9()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 8 To 80 Step 9
For j = i + 9 To 80 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(17).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(17).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Private Sub Box_Change(Index As Integer)
cekkolom1
cekkolom2
cekkolom3
cekkolom4
cekkolom5
cekkolom6
cekkolom7
cekkolom8
cekkolom9
cekbaris1
cekbaris2
cekbaris3
cekbaris4
cekbaris5
cekbaris6
cekbaris7
cekbaris8
cekbaris9
ceksemua
End Sub
Sub ceksemua()
Dim i As Integer
Dim menang As Boolean
menang = True
For i = 0 To 17
If ket(i).Picture = salah.Picture Then
menang = False
Exit For
Exit Sub
End If
Next i
If menang = True Then
Call menang1
End If
End Sub
Private Sub Command1_Click()
For i = 0 To 80
box(i).Text = ""
Next i
Call p1
tjam.Enabled = False
tjam.Enabled = True
ss = 0
mm = 0
End Sub
Private Sub Command2_Click()
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 17
ket(i).Picture = salah.Picture
Next i
For i = 0 To 80
box(i).BackColor = RGB(204, 153, 102)
Next i
End Sub
Sub menang1()
MsgBox "Selamat anda menang !", vbOKOnly, "Selesai"
Timer1.Enabled = True
tjam.Enabled = False
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lmulai.ForeColor = vbWhite
End Sub
Private Sub lmulai_Click()
tframe.Enabled = True
End Sub
Private Sub lmulai_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lmulai.ForeColor = RGB(204, 153, 102)
End Sub
Private Sub tframe_Timer()
Frame1.Top = Frame1.Top - 10
If Frame1.Top = 120 Or Frame1.Top < 120 Then
tframe.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Dim k As Integer
For k = 0 To 80
box(k).ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next k
End Sub
Sub pasang(nomor As Integer, isi As String)
box(nomor).Text = isi
box(nomor).Locked = True
End Sub
Sub p1()
Call pasang(0, "3")
Call pasang(1, "1")
Call pasang(2, "2")
Call pasang(9, "5")
Call pasang(11, "9")
Call pasang(18, "4")
Call pasang(20, "7")
'-------------------
Call pasang(3, "8")
Call pasang(4, "9")
Call pasang(5, "5")
Call pasang(12, "1")
Call pasang(14, "7")
Call pasang(21, "2")
Call pasang(23, "3")
'-------------------
Call pasang(6, "4")
Call pasang(7, "7")
Call pasang(8, "6")
Call pasang(16, "8")
Call pasang(24, "5")
Call pasang(26, "9")
'-------------------
Call pasang(27, "9")
Call pasang(36, "7")
Call pasang(38, "8 ")
Call pasang(45, "6")
'-------------------
Call pasang(30, "7")
Call pasang(40, "1")
Call pasang(48, "9")
Call pasang(49, "8")
Call pasang(50, "2")
'-------------------
Call pasang(33, "2")
Call pasang(34, "4")
Call pasang(43, "9")
Call pasang(44, "3")
Call pasang(52, "5")
Call pasang(53, "7")
'-------------------
Call pasang(54, "2")
Call pasang(63, "1")
Call pasang(64, "7 ")
Call pasang(65, "6")
Call pasang(72, "8")
'-------------------
Call pasang(57, "6")
Call pasang(66, "3")
Call pasang(67, "5")
Call pasang(68, "8")
Call pasang(75, "4")
Call pasang(76, "2")
'-------------------
Call pasang(61, "3")
Call pasang(62, "1")
Call pasang(69, "9")
Call pasang(71, "4")
Call pasang(78, "7")
Call pasang(80, "5")
End Sub
Private Sub tjam_Timer()
ss = ss + 1
If ss = 60 Then
ss = 0
mm = mm + 1
End If
If Len(CStr(ss)) = 1 Then
sec = "0" & ss
Else
sec = ss
End If
If Len(CStr(mm)) = 1 Then
Min = "0" & mm
Else
Min = mm
End If
End Sub
form 4 :
script :
Dim ss As Integer
Dim mm As Integer
Sub cekkolom1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 8
For j = i + 1 To 8
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(0).Picture = salah.Picture
Exit Sub
Else
ket(0).Picture = benar.Picture
End If
Next j
Next i
'------------------------
End Sub
Sub cekkolom2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 9 To 17
For j = i + 1 To 17
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(1).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(1).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 18 To 26
For j = i + 1 To 26
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(2).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(2).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 27 To 35
For j = i + 1 To 35
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(3).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(3).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 36 To 44
For j = i + 1 To 44
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(4).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(4).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 45 To 53
For j = i + 1 To 53
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(5).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(5).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom7()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 54 To 62
For j = i + 1 To 62
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(6).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(6).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom8()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 63 To 71
For j = i + 1 To 71
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(7).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(7).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekkolom9()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 72 To 80
For j = i + 1 To 80
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(8).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(8).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris1()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 0 To 72 Step 9
For j = i + 9 To 72 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(9).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(9).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris2()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 1 To 73 Step 9
For j = i + 9 To 73 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(10).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(10).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris3()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 2 To 74 Step 9
For j = i + 9 To 74 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(11).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(11).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris4()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 3 To 75 Step 9
For j = i + 9 To 75 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(12).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(12).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris5()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 4 To 76 Step 9
For j = i + 9 To 76 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(13).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(13).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris6()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 5 To 77 Step 9
For j = i + 9 To 77 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(14).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(14).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris7()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 6 To 78 Step 9
For j = i + 9 To 78 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(15).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(15).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris8()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 7 To 79 Step 9
For j = i + 9 To 79 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(16).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(16).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Sub cekbaris9()
Dim i As Integer, j As Integer, angka As Integer
'cek ke kanan baris 1
For i = 8 To 80 Step 9
For j = i + 9 To 80 Step 9
angka = Val(box(i).Text)
'jika ada yg dobel
If angka = Val(box(j).Text) Or box(j).Text = "" Then
ket(17).Picture = salah.Picture
'Box(j).SetFocus
Exit Sub
Else
ket(17).Picture = benar.Picture
End If
Next j
'End If
Next i
'------------------------
End Sub
Private Sub Box_Change(Index As Integer)
cekkolom1
cekkolom2
cekkolom3
cekkolom4
cekkolom5
cekkolom6
cekkolom7
cekkolom8
cekkolom9
cekbaris1
cekbaris2
cekbaris3
cekbaris4
cekbaris5
cekbaris6
cekbaris7
cekbaris8
cekbaris9
ceksemua
End Sub
Sub ceksemua()
Dim i As Integer
Dim menang As Boolean
menang = True
For i = 0 To 17
If ket(i).Picture = salah.Picture Then
menang = False
Exit For
Exit Sub
End If
Next i
If menang = True Then
Call menang1
End If
End Sub
Private Sub Command1_Click()
For i = 0 To 80
box(i).Text = ""
Next i
Call p1
tjam.Enabled = False
tjam.Enabled = True
ss = 0
mm = 0
End Sub
Private Sub Command2_Click()
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 17
ket(i).Picture = salah.Picture
Next i
For i = 0 To 80
box(i).BackColor = RGB(204, 153, 102)
Next i
End Sub
Sub menang1()
MsgBox "Selamat anda menang !", vbOKOnly, "Selesai"
Timer1.Enabled = True
tjam.Enabled = False
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lmulai.ForeColor = vbWhite
End Sub
Private Sub lmulai_Click()
tframe.Enabled = True
End Sub
Private Sub lmulai_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lmulai.ForeColor = RGB(204, 153, 102)
End Sub
Private Sub Label2_Click()
End
End Sub
Private Sub tframe_Timer()
Frame1.Top = Frame1.Top - 10
If Frame1.Top = 120 Or Frame1.Top < 120 Then
tframe.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Dim k As Integer
For k = 0 To 80
box(k).ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next k
End Sub
Sub pasang(nomor As Integer, isi As String)
box(nomor).Text = isi
box(nomor).Locked = True
End Sub
Sub p1()
Call pasang(0, "9")
Call pasang(2, "5")
Call pasang(20, "7")
'-------------------
Call pasang(4, "2")
Call pasang(12, "5")
Call pasang(14, "9")
'-------------------
Call pasang(8, "8")
Call pasang(16, "2")
Call pasang(26, "5")
'-------------------
Call pasang(36, "7")
Call pasang(38, "4 ")
'-------------------
Call pasang(30, "7")
Call pasang(40, "1")
Call pasang(48, "9")
Call pasang(50, "5")
'-------------------
Call pasang(33, "5")
Call pasang(34, "1")
Call pasang(53, "4")
'-------------------
Call pasang(54, "6")
Call pasang(65, "9")
Call pasang(72, "5")
'-------------------
Call pasang(66, "8")
Call pasang(67, "6")
Call pasang(76, "9")
'-------------------
Call pasang(61, "9")
Call pasang(69, "4")
Call pasang(78, "8")
End Sub
Private Sub tjam_Timer()
ss = ss + 1
If ss = 60 Then
ss = 0
mm = mm + 1
End If
If Len(CStr(ss)) = 1 Then
sec = "0" & ss
Else
sec = ss
End If
If Len(CStr(mm)) = 1 Then
Min = "0" & mm
Else
Min = mm
End If
End Sub
sumber :
https://id.wikipedia.org/wiki/Sudoku
http://sintuble.blogspot.co.id/2012/02/cara-buat-game-sudoku-dengan-vb-visual.html
Tidak ada komentar:
Posting Komentar