Cara Membuat Aplikasi Sistem Pakar di Visual Basic

"Silahkan kunjungi postingan Cara Membuat Aplikasi Sistem Pakar di Visual Basic untuk membaca artikel selengkapnya dengan klik link di atas."

10 min read
Cara Membuat Aplikasi Sistem Pakar di Visual Basic - Sistem pakar (expert system) adalah salah satu cabang dalam artificial intellgence atau kecerdasan buatan. Pada kesempatan ini, kita akan belajar cara sederhana membuat sistem pakar menggunakan aplikasi Visual Basic 6.0.

Dibandingkan dengan Visual Studio, bagi saya Visual Basic lebih mudah. Selain itu, aplikasi Visual Basic juga lebih ringan dibandingkan dengan Visual Studio.

Pada kasus ini, kita akan mencoba membuat aplikasi sistem pakar tes buta warna metode Ishihara. Awalnya saya ingin membuat sistem pakar Visual Basic dengan metode forward chaining. Tapi hasilnya berakhir dengan sebuah aplikasi tes buta warna berbasis komputer menggunakan metode Ishihara yang hanya menggunakan fungsi IF ... THEN memanfaatkan checkbox. Seperti kuis Matematika aja. Untuk sistem pakar yang asli menggunakan forward chaining nanti diposting jika sudah ada waktu luang.

Contoh Aplikasi Sistem Pakar Visual Basic


Aplikasi tes buta warna berbasis Visual Basic ini dapat mendiagnosa:
  • Mata Normal
  • Buta warna ringan
  • Buta warna sedang
  • Buta warna berat
Ada 10 plat Ishihara yang harus dijawab. Setiap plat Ishihara dilengkapi dengan satu jawaban yang tepat dari 4 pilihan. Sebenarnya ini sama saja dengan kuis pilihan ganda.

Jadi di sini hanya memanfaatkan fungsi IF ... THEN, yaitu jika ada 2 soal yang benar maka akan buta warna berat. Jika ada 8 yang benar, maka mata normal. Jika kondisi tidak memenuhi, maka pilihan harus dijawab lagi untuk memenuhi kondisi.

Buat Form1

Desain form seperti tampilan di bawah ini!

 Aplikasi Buta Warna Visual Basic 6.0
Aplikasi Buta Warna Visual Basic 6.0

Klik 2 kali form dan hapus semua listing di dalamnya. Kemudian paste kode berikut ini:

Private Sub Check1_Click()
If Check1.Value = Checked Then
Check2.Value = Unchecked
Check22.Value = Unchecked
Check23.Value = Unchecked
End If
End Sub

Private Sub Check10_Click()
If Check10.Value = Checked Then
Check9.Value = Unchecked
Check37.Value = Unchecked
Check38.Value = Unchecked
End If
End Sub

Private Sub Check11_Click()
If Check11.Value = Checked Then
Check12.Value = Unchecked
Check29.Value = Unchecked
Check30.Value = Unchecked
End If
End Sub

Private Sub Check12_Click()
If Check12.Value = Checked Then
Check11.Value = Unchecked
Check29.Value = Unchecked
Check30.Value = Unchecked
End If
End Sub

Private Sub Check13_Click()
If Check13.Value = Checked Then
Check14.Value = Unchecked
Check32.Value = Unchecked
Check31.Value = Unchecked
End If
End Sub

Private Sub Check14_Click()
If Check14.Value = Checked Then
Check13.Value = Unchecked
Check32.Value = Unchecked
Check31.Value = Unchecked
End If
End Sub

Private Sub Check15_Click()
If Check15.Value = Checked Then
Check16.Value = Unchecked
Check34.Value = Unchecked
Check33.Value = Unchecked
End If
End Sub

Private Sub Check16_Click()
If Check16.Value = Checked Then
Check15.Value = Unchecked
Check34.Value = Unchecked
Check33.Value = Unchecked
End If
End Sub

Private Sub Check17_Click()
If Check17.Value = Checked Then
Check18.Value = Unchecked
Check35.Value = Unchecked
Check36.Value = Unchecked
End If
End Sub

Private Sub Check18_Click()
If Check18.Value = Checked Then
Check17.Value = Unchecked
Check35.Value = Unchecked
Check36.Value = Unchecked
End If
End Sub

Private Sub Check19_Click()
If Check19.Value = Checked Then
Check20.Value = Unchecked
Check39.Value = Unchecked
Check40.Value = Unchecked
End If
End Sub

Private Sub Check2_Click()
If Check2.Value = Checked Then
Check1.Value = Unchecked
Check22.Value = Unchecked
Check23.Value = Unchecked
End If
End Sub

Private Sub Check20_Click()
If Check20.Value = Checked Then
Check19.Value = Unchecked
Check39.Value = Unchecked
Check40.Value = Unchecked
End If
End Sub

Private Sub Check21_Click()
If Check21.Value = Checked Then
Check4.Value = Unchecked
Check3.Value = Unchecked
Check24.Value = Unchecked
End If
End Sub

Private Sub Check22_Click()
If Check22.Value = Checked Then
Check1.Value = Unchecked
Check2.Value = Unchecked
Check23.Value = Unchecked
End If
End Sub

Private Sub Check23_Click()
If Check23.Value = Checked Then
Check1.Value = Unchecked
Check22.Value = Unchecked
Check2.Value = Unchecked
End If
End Sub

Private Sub Check24_Click()
If Check24.Value = Checked Then
Check4.Value = Unchecked
Check21.Value = Unchecked
Check3.Value = Unchecked
End If
End Sub

Private Sub Check25_Click()
If Check25.Value = Checked Then
Check6.Value = Unchecked
Check5.Value = Unchecked
Check26.Value = Unchecked
End If
End Sub

Private Sub Check26_Click()
If Check26.Value = Checked Then
Check6.Value = Unchecked
Check25.Value = Unchecked
Check5.Value = Unchecked
End If
End Sub

Private Sub Check27_Click()
If Check27.Value = Checked Then
Check8.Value = Unchecked
Check7.Value = Unchecked
Check28.Value = Unchecked
End If
End Sub

Private Sub Check28_Click()
If Check28.Value = Checked Then
Check8.Value = Unchecked
Check27.Value = Unchecked
Check7.Value = Unchecked
End If
End Sub

Private Sub Check29_Click()
If Check29.Value = Checked Then
Check12.Value = Unchecked
Check11.Value = Unchecked
Check30.Value = Unchecked
End If
End Sub

Private Sub Check3_Click()
If Check3.Value = Checked Then
Check4.Value = Unchecked
Check21.Value = Unchecked
Check24.Value = Unchecked
End If
End Sub

Private Sub Check30_Click()
If Check30.Value = Checked Then
Check12.Value = Unchecked
Check29.Value = Unchecked
Check11.Value = Unchecked
End If
End Sub

Private Sub Check31_Click()
If Check31.Value = Checked Then
Check14.Value = Unchecked
Check32.Value = Unchecked
Check13.Value = Unchecked
End If
End Sub

Private Sub Check32_Click()
If Check32.Value = Checked Then
Check14.Value = Unchecked
Check13.Value = Unchecked
Check31.Value = Unchecked
End If
End Sub

Private Sub Check33_Click()
If Check33.Value = Checked Then
Check34.Value = Unchecked
Check15.Value = Unchecked
Check16.Value = Unchecked
End If
End Sub

Private Sub Check34_Click()
If Check34.Value = Checked Then
Check15.Value = Unchecked
Check16.Value = Unchecked
Check33.Value = Unchecked
End If
End Sub

Private Sub Check35_Click()
If Check35.Value = Checked Then
Check18.Value = Unchecked
Check17.Value = Unchecked
Check36.Value = Unchecked
End If
End Sub

Private Sub Check36_Click()
If Check36.Value = Checked Then
Check18.Value = Unchecked
Check35.Value = Unchecked
Check17.Value = Unchecked
End If
End Sub

Private Sub Check37_Click()
If Check37.Value = Checked Then
Check10.Value = Unchecked
Check9.Value = Unchecked
Check38.Value = Unchecked
End If
End Sub

Private Sub Check38_Click()
If Check38.Value = Checked Then
Check10.Value = Unchecked
Check37.Value = Unchecked
Check9.Value = Unchecked
End If
End Sub

Private Sub Check39_Click()
If Check39.Value = Checked Then
Check20.Value = Unchecked
Check19.Value = Unchecked
Check40.Value = Unchecked
End If
End Sub

Private Sub Check4_Click()
If Check4.Value = Checked Then
Check3.Value = Unchecked
Check21.Value = Unchecked
Check24.Value = Unchecked
End If
End Sub

Private Sub Check40_Click()
If Check40.Value = Checked Then
Check20.Value = Unchecked
Check39.Value = Unchecked
Check19.Value = Unchecked
End If
End Sub

Private Sub Check5_Click()
If Check5.Value = Checked Then
Check6.Value = Unchecked
Check25.Value = Unchecked
Check26.Value = Unchecked
End If
End Sub

Private Sub Check6_Click()
If Check6.Value = Checked Then
Check5.Value = Unchecked
Check25.Value = Unchecked
Check26.Value = Unchecked
End If
End Sub

Private Sub Check7_Click()
If Check7.Value = Checked Then
Check8.Value = Unchecked
Check27.Value = Unchecked
Check28.Value = Unchecked
End If
End Sub

Private Sub Check8_Click()
If Check8.Value = Checked Then
Check7.Value = Unchecked
Check27.Value = Unchecked
Check28.Value = Unchecked
End If
End Sub

Private Sub Check9_Click()
If Check9.Value = Checked Then
Check10.Value = Unchecked
Check37.Value = Unchecked
Check38.Value = Unchecked
End If
End Sub

Private Sub Command1_Click()
a = Check1
b = Check3
c = Check5
d = Check7
e = Check9
f = Check11
g = Check13
h = Check15
i = Check17
j = Check19
aa = Check2
bb = Check4
cc = Check6
dd = Check8
ee = Check10
ff = Check12
gg = Check14
hh = Check16
ii = Check18
jj = Check120
jj1 = Check21
jj2 = Check22
jj3 = Check23
jj4 = Check24
jj5 = Check25
jj6 = Check26
jj7 = Check27
jj8 = Check28
jj9 = Check29
jj10 = Check30
jj11 = Check31
jj12 = Check32
jj13 = Check33
jj14 = Check34
jj15 = Check35
jj16 = Check36
jj17 = Check37
jj18 = Check38
jj19 = Check39
jj20 = Check40

If a And b And c And d And e And f And g And h And i And j = Checked Then
Text1.BackColor = vbGreen
Text1.Text = "Mata Anda Normal, Anda Lulus Tes!"
End If
If aa And bb And cc And dd And ee And ff And gg And hh And ii And jj = Checked Then
Text1.BackColor = vbRed
Text1.Text = "Buta Warna Total, Maaf Anda Tidak Lulus Tes!"
End If

x = a + b + c + d + e + f + g + h + i + j
y = aa + bb + cc + dd + ee + ff + gg + hh + ii + jj + jj1 + jj2 + jj3 + jj4 + jj5 + jj6 + jj7 + jj8 + jj9 + jj10 + jj11 + jj12 + jj13 + jj14 + jj15 + jj16 + jj17 + jj18 + jj19 + jj20

If x < 8 = Cheked Then
Text1.Text = "Mata Normal, Anda Lulus Tes!"
Text1.BackColor = vbGreen
ElseIf y < 5 = Cheked Then
Text1.Text = "Buta Warna Berat, Maaf Anda Tidak Lulus!"
Text1.BackColor = vbRed
ElseIf y < 3 = Cheked Then
Text1.Text = "Buta Warna Sedang, Maaf Anda Tidak Lulus!"
Text1.BackColor = vbBlue
ElseIf y < 2 = Cheked Then
Text1.Text = "Buta Warna Ringan, Maaf Anda Tidak Lulus!"
Text1.BackColor = vbWhite
Else
Text1.Text = "Isi Semua dari Nomor 1 - 20!!"
Text1.BackColor = vbYellow
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text1.BackColor = vbWhite
End Sub

Private Sub Command3_Click()
Form2.Show
Unload Me
End Sub

Private Sub Command4_Click()
Form3.Show
Unload Me
End Sub

Private Sub Command5_Click()
Command5.BackColor = vbRed
Unload Me
End Sub



Buat Form2

Desain form2 seperti tampilan di bawah ini!

 Form utama aplikasi buta warna
Form utama aplikasi buta warna

Setelah itu, klik 2 kali form2 dan hapus semua listing di dalamnya. Kemudian pastekan kode berikut!

Private Sub Command1_Click()
Form4.Show
Unload Me
End Sub

Private Sub Command2_Click()
Form3.Show
Unload Me
End Sub

Private Sub Command6_Click()
Unload Me
End Sub


Buat Form3

Desain form3 seperti tampilan di bawah ini!

 Form about aplikasi buta warna
Form about aplikasi buta warna

Setelah itu, klik 2 kali form3 dan hapus semua listing di dalamnya. Kemudian pastekan kode berikut!

Private Sub Command1_Click()
Form2.Show
Unload Me
End Sub


Buat Form4

Desain form4 seperti tampilan di bawah ini!

 Form Login Aplikasi Buta Warna
Form Login Aplikasi Buta Warna

Setelah itu, klik 2 kali form4 dan hapus semua listing di dalamnya. Kemudian pastekan kode berikut!

Private Sub cmdCancel_Click()
Form2.Show
Unload Me
End Sub

Private Sub cmdOK_Click()
nama = ""
    If txtPassword = "admin" Then
        LoginSucceeded = True
        Me.Hide
        Form1.Show
    Else
        MsgBox "Maaf, Password Anda Salah!", vbCritical, "Salah Password"
    End If
End Sub

Sebelum dijalankan aplikasinya, ubah dulu startup project ke form2. Setting di project properties.

Pada aplikasi tes buta warna Visual Basic ini, kita tidak menggunakan database Access ataupun SQL Server atau pun lainnya. Murni koding menggunakan fungsi IF pada Visual Basic.

Apakah ini bisa disebut sistem pakar?

Jika dikembangkan mungkin. Namun pada contoh ini tidak lebih dari pemanfaatan fungsi IF ... THEN seperti pada kuis Matematika aja. 

Demikianlah cara membuat aplikasi sistem pakar sederhana di Visual Basic untuk tes buta warna. Semoga bermanfaat!
Posting Komentar