Visual Basic : Kalkulator

1. Perkalian 2 bilangan

shofiatun1

Private Sub Command1_Click()

Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

Private Sub Command2_Click()

Text1.Text = “”

Text2.Text = “”

Text3.Text = “”

End Sub

Private Sub Command3_Click()

End

End Sub

2. Kalkulator mini

shofiatun2

Private Sub Command1_Click()

Text3.Text = Val(Text1.Text) + Val(Text2.Text)

Text4.Text = Val(Text1.Text) * Val(Text2.Text)

Text5.Text = Val(Text1.Text) – Val(Text2.Text)

Text6.Text = Val(Text1.Text) / Val(Text2.Text)

End Sub

Private Sub Command2_Click()

Text1.Text = “”

Text2.Text = “”

Text3.Text = “”

Text4.Text = “”

Text5.Text = “”

Text6.Text = “”

End Sub

Private Sub Command3_Click()

End

End Sub

3. Perhitungan Harga Setelah Diskon 10%

shofiatun3

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.Text = Val(Text1.Text) * 0.1

Text3.Text = Val(Text1.Text) – Val(Text2.Text)

End If

End Sub