Membuat Program Kalkulator | Visual Basic 2010
recudo.com - Disini admin akan memberikan seuah program tentang tutorial membuat kalkulator dengan Microsoft Visual Studio 2010. Hal utama yang harus kalian lakukan adalah kalian harus mempunyai progam Visual Studio 2010. Apabila kalian tidak mempunyai Program Microsoft Visual Studio 2010. Disini admin akan memberikan link untuk mendownload Visual Studio 2010.
Apabila sudah kalian install tahap pertama nya...
1. Buka program Microsoft Visual Studio,setelah program terbuka pilih File-New Project-Visual Basic-Windows Forms Application-Ok
2. Buat From seperti ini:
Disini admin menggunakan Toolbox seperti "TextBox" dan "Button"
3. Klik 2x Form pada Form 1
Lalu copy paste coding seperti ini
Public Class Form1
Dim FirstNumber As Single
Dim SecondNumber As Single
Dim AnswerNumber As Single
Dim ArithmeticProcess As String
4. Setelah itu klik satu per satu tool button pada menu form
Lalu masukkan coding seperti ini
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
txtHasil.Text = txtHasil.Text & 0
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtHasil.Text = txtHasil.Text & 1
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtHasil.Text = txtHasil.Text & 2
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtHasil.Text = txtHasil.Text & 3
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtHasil.Text = txtHasil.Text & 4
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtHasil.Text = txtHasil.Text & 5
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtHasil.Text = txtHasil.Text & 6
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtHasil.Text = txtHasil.Text & 7
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtHasil.Text = txtHasil.Text & 8
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtHasil.Text = txtHasil.Text & 9
End Sub
Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTambah.Click
FirstNumber = Val(txtHasil.Text)
txtHasil.Text = ""
ArithmeticProcess = "+"
End Sub
Private Sub btnKurang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKurang.Click
FirstNumber = Val(txtHasil.Text)
txtHasil.Text = ""
ArithmeticProcess = "-"
End Sub
Private Sub btnBagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBagi.Click
FirstNumber = Val(txtHasil.Text)
txtHasil.Text = ""
ArithmeticProcess = "/"
End Sub
Private Sub btnKali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKali.Click
FirstNumber = Val(txtHasil.Text)
txtHasil.Text = ""
ArithmeticProcess = "*"
End Sub
Private Sub btnHasil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHasil.Click
SecondNumber = Val(txtHasil.Text)
If ArithmeticProcess = "+" Then
AnswerNumber = FirstNumber + SecondNumber
End If
If ArithmeticProcess = "-" Then
AnswerNumber = FirstNumber - SecondNumber
End If
If ArithmeticProcess = "/" Then
AnswerNumber = FirstNumber / SecondNumber
End If
If ArithmeticProcess = "*" Then
AnswerNumber = FirstNumber * SecondNumber
End If
txtHasil.Text = AnswerNumber
End Sub
Private Sub btnCE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCE.Click
txtHasil.Text = ""
End Sub
5. Setelah kalian memasukkan coding seperi ini, disini akan keluar hasil seperti ini:
Keterangan :
Kalian pun harus mengklik satu persatu disetiap button.
Dari coding diatas kalian harus merubah satu persatu contoh nya seperti ini:
Button 0 => btn0
Button 1 => btn1
Button 2 => btn2
Button 3 => btn3
Button 4 => btn4
Button 5 => btn5
Button 6 => btn6
Button 7 => btn7
Button 8 => btn8
Button 9 => btn9
Button CE => btnCE
Button = => btnHasil
Button + => btnTambah
Button - => btnKurang
Button * => btnKali
Button / => btnBagi
Terima kasih untuk kalian yang telah mengunjungi artikel ini, semoga dapat bermanfaat dan semoga membantu kalian untuk mengerjakan tugas kalian,
Dan tetap nantikan artikel menarik dari recudo yah.
EmoticonEmoticon