0% found this document useful (0 votes)
24 views

Praktek Responsi 2 (Coding)

The document describes a Visual Basic application for performing calculations. It defines variables to store numbers and operators, includes buttons for numbers 0-9 and operators like addition and subtraction, and code to handle button clicks by adding numbers to a display or clearing and storing values for calculations based on the selected operator. The application performs the calculations and displays the result when the equals button is clicked.

Uploaded by

DWI SETIA RINI
Copyright
© © All Rights Reserved
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)
24 views

Praktek Responsi 2 (Coding)

The document describes a Visual Basic application for performing calculations. It defines variables to store numbers and operators, includes buttons for numbers 0-9 and operators like addition and subtraction, and code to handle button clicks by adding numbers to a display or clearing and storing values for calculations based on the selected operator. The application performs the calculations and displays the result when the equals button is clicked.

Uploaded by

DWI SETIA RINI
Copyright
© © All Rights Reserved
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

PRAKTEK RESPONSI 2

APLIKASI PERHITUNGAN

1. Form
Pada Form1 (Pemberian Variabel)
Dim Angka1, Angka2 As Single
Dim lambang As String

2.Tombol Angka
CmdAngka1_Click
Display.Text = Display.Text + CmdAngka1.Text

CmdAngka2_Click
Display.Text = Display.Text + CmdAngka2.Text

CmdAngka3_Click
Display.Text = Display.Text + CmdAngka3.Text

CmdAngka4_Click
Display.Text = Display.Text + CmdAngka4.Text

CmdAngka5_Click
Display.Text = Display.Text + CmdAngka5.Text

CmdAngka6_Click
Display.Text = Display.Text + CmdAngka6.Text

CmdAngka7_Click
Display.Text = Display.Text + CmdAngka7.Text

CmdAngka8_Click
Display.Text = Display.Text + CmdAngka8.Text

CmdAngka9_Click
Display.Text = Display.Text + CmdAngka9.Text

CmdAngka0_Click
If Display.Text = "" Then
Display.Text = ""

Else
Display.Text = Display.Text + CmdAngka0.Text
End If
2. Operator

Bersih_Click
Display.Text = ""

Tambah_Click
If Display.Text = "" Then Exit Sub
Angka1 = CSng(Display.Text)
lambang = "+"
Display.Clear()

Kurang_Click
If Display.Text = "" Then Exit Sub
Angka1 = CSng(Display.Text)
lambang = "-"
Display.Clear()

Kali_Click
If Display.Text = "" Then Exit Sub
Angka1 = CSng(Display.Text)
lambang = "*"
Display.Clear()

Bagi_Click
If Display.Text = "" Then Exit Sub
Angka1 = CSng(Display.Text)
lambang = "/"
Display.Clear()

Samadengan_Click
Dim hasil As Single
Angka2 = CSng(Display.Text)
Select Case lambang
Case "+"
hasil = Angka1 + Angka2
Case "-"
hasil = Angka1 - Angka2
Case "*"
hasil = Angka1 * Angka2
Case "/"
hasil = Angka1 / Angka2
End Select
Display.Text = hasil
PlusMinus_Click
If Display.Text = "" Then Exit Sub
If Val(Display.Text) > 0 Then
Display.Text = Val(Display.Text) * -1
Else
Display.Text = Val(Display.Text) * -1
End If

Koma_Click
Display.Text = Display.Text + Koma.Text

You might also like