Kalkulator adalah alat hitung yang memudahkan penghitungan
manusia. pada article ini akan menjelaskan toolbox yang digunakan untuk membuat
program kalkulator standart dengan VISUAL BASIC 2008 atau biasa disebut
VIBI.NET
Toolbox :
1 TEXTBOX
16 BUTTON
CODING
Public Class Form1
Dim nilaia As Double
Dim nilaib As Double
Dim hasil As Integer
Dim opsi As String
“ coding yang menjelaskan variabelyang digunakan
Double, integer dan string “
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text & Button1.Text
“Coding untuk menampilkan angka pada button. Button1 untuk angka 1
hingga button10 untuk angka 0 “
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = TextBox1.Text & Button2.Text
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = TextBox1.Text & Button3.Text
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox1.Text = TextBox1.Text & Button4.Text
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox1.Text = TextBox1.Text & Button5.Text
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox1.Text = TextBox1.Text & Button6.Text
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TextBox1.Text = TextBox1.Text & Button7.Text
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TextBox1.Text = TextBox1.Text & Button8.Text
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
TextBox1.Text = TextBox1.Text & Button9.Text
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
TextBox1.Text = TextBox1.Text & Button10.Text
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
TextBox1.Text
= ""
“ Coding untuk button16 yang berisi perintah clear pada textbox “
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
opsi = "+"
nilaia
= Val(TextBox1.Text)
TextBox1.Text = ""
“ Coding untuk menampilkan dan mengoperasikan + ,
- , x dan : “
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
opsi = "-"
nilaia
= Val(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
opsi = "x"
nilaia
= Val(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
opsi = "/"
nilaia
= Val(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
nilaib = Val(TextBox1.Text)
Select Case opsi
Case "+"
hasil = nilaia + nilaib
Case "-"
hasil = nilaia - nilaib
Case "x"
hasil = nilaia * nilaib
Case "/"
hasil = nilaia / nilaib
End Select
TextBox1.Text = hasil
End Sub
End Class
“ Coding untuk mengoperasikan button hasil (=) “
1 komentar:
Terima kasih
Infonya sangat bermanfaat
Posting Komentar