Pada tutorial kali ini, kita akan membahas mengenai cara membuat kalkulator sederhana dengan Visual Basic 6.
Kalkulator sederhana ini mempunyai keunikan yaitu kita bisa mengetahui proses penyamaan penyebutnya.
Oke Let's Start . .
1. Buka Visual Basic 6
2. Klik Open
3. Lalu buat form seperti gambar dibawah ini.
4. Lalu klik 2x pada "Button +", maka akan keluar sebuah window baru tempat kita mengetikan codingnya.
Ketik coding berikut untuk :
1. Penjumlahan
Private Sub Command1_Click()
Text6.Text = Val(Text2.Text) * Val(Text4.Text)
Text8.Text = Val(Text2.Text) * Val(Text4.Text)
Text5.Text = (Val(Text6.Text) / Val(Text2.Text)) * Val(Text1.Text)
Text7.Text = (Val(Text8.Text) / Val(Text4.Text)) * Val(Text3.Text)
Text9.Text = Val(Text5.Text) + Val(Text7.Text)
Text10.Text = Val(Text2.Text) * Val(Text4.Text)
End Sub
2. Pengurangan
Private Sub Command2_Click()
Text6.Text = Val(Text2.Text) * Val(Text4.Text)
Text8.Text = Val(Text2.Text) * Val(Text4.Text)
Text5.Text = (Val(Text6.Text) / Val(Text2.Text)) * Val(Text1.Text)
Text7.Text = (Val(Text8.Text) / Val(Text4.Text)) * Val(Text3.Text)
Text9.Text = Val(Text5.Text) - Val(Text7.Text)
Text10.Text = Val(Text2.Text) * Val(Text4.Text)
End Sub
3. Perkalian
Private Sub Command3_Click()
Text5.Text = Text1.Text
Text6.Text = Text2.Text
Text7.Text = Text3.Text
Text8.Text = Text4.Text
Text9.Text = Val(Text5.Text) * Val(Text7.Text)
Text10.Text = Val(Text6.Text) * Val(Text8.Text)
End Sub
4. Pembagian
Private Sub Command4_Click()
Text5.Text = Text1.Text
Text6.Text = Text2.Text
Text7.Text = Text4.Text
Text8.Text = Text3.Text
Text9.Text = Val(Text5.Text) * Val(Text7.Text)
Text10.Text = Val(Text6.Text) * Val(Text8.Text)
End Sub
Setelah selesai kalian bisa langsung klik tombol Run atau Play untuk mengcompile codingan kalian, bila berhasil akan terlihat seperti ini,
Penjumlahan
Pengurangan
Perkalian
Pembagian




ConversionConversion EmoticonEmoticon