0% found this document useful (0 votes)
58 views3 pages

Kalkulator Mini

This document contains code for a calculator application created in Visual Studio by a student named Yayat Hidayat. The code defines the form layout and includes methods for each button click event to perform calculation operations or display numbers/symbols. On button clicks, numbers are appended to a text box, calculations are performed and displayed, and variables store intermediate values. The code allows for addition, subtraction, multiplication, and division functions.

Uploaded by

Abu Nayya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views3 pages

Kalkulator Mini

This document contains code for a calculator application created in Visual Studio by a student named Yayat Hidayat. The code defines the form layout and includes methods for each button click event to perform calculation operations or display numbers/symbols. On button clicks, numbers are appended to a text box, calculations are performed and displayed, and variables store intermediate values. The code allows for addition, subtraction, multiplication, and division functions.

Uploaded by

Abu Nayya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Nama : Yayat Hidayat

Nim : 20080911226
Kelas : SIC2008

Tugas BP3 membuat kalkulator dengan visual studio

Sintax :
Public Class Form1

Inherits System.Windows.Forms.Form
Const pi As Single = 3.14
Public hasil As Single
Friend WithEvents Button19 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Public [operator] As Byte

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button9.Click
TextBox1.Text = TextBox1.Text & pi
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button13.Click
TextBox1.Text = ""
hasil = 0
TextBox1.Focus()
End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button14.Click
[operator] = "1"
hasil = Single.Parse(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button15.Click
[operator] = "2"
hasil = Single.Parse(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button16.Click
[operator] = "3"
hasil = Single.Parse(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button17.Click
[operator] = "4"
hasil = Single.Parse(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button18.Click
If [operator] = 1 Then
hasil += Single.Parse(TextBox1.Text)
TextBox1.Text = hasil
ElseIf [operator] = 2 Then
hasil -= Single.Parse(TextBox1.Text)
TextBox1.Text = hasil
ElseIf [operator] = 3 Then
hasil *= Single.Parse(TextBox1.Text)
TextBox1.Text = hasil
ElseIf [operator] = 4 Then
hasil /= Single.Parse(TextBox1.Text)
TextBox1.Text = hasil

End If
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click
TextBox1.Text = TextBox1.Text + "."
TextBox1.Focus()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
TextBox1.Text = TextBox1.Text & "0"

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
TextBox1.Text = TextBox1.Text & "1"
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
TextBox1.Text = TextBox1.Text & "2"
End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button12.Click
TextBox1.Text = TextBox1.Text & "3"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
TextBox1.Text = TextBox1.Text & "4"
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Text = TextBox1.Text & "5"
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button11.Click
TextBox1.Text = TextBox1.Text & "6"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text & "7"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
TextBox1.Text = TextBox1.Text & "8"
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button10.Click
TextBox1.Text = TextBox1.Text & "9"
End Sub

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button19.Click
End
End Sub
End Class
Output :

You might also like