This document contains the code for a basic calculator application. It defines classes and subroutines to handle button clicks and operations for numbers, arithmetic operators, and functions. Buttons can be enabled and disabled to turn the calculator on and off. Number buttons add digits to the display, while operator buttons set the calculation type and clear the display. The equal button performs the calculation and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
38 views4 pages
KODING
This document contains the code for a basic calculator application. It defines classes and subroutines to handle button clicks and operations for numbers, arithmetic operators, and functions. Buttons can be enabled and disabled to turn the calculator on and off. Number buttons add digits to the display, while operator buttons set the calculation type and clear the display. The equal button performs the calculation and displays the result.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text & "1" End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = TextBox1.Text & "2" End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
TextBox1.Text = TextBox1.Text & "3" End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
TextBox1.Text = TextBox1.Text & "4" End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox1.Text = TextBox1.Text & "5" End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
TextBox1.Text = TextBox1.Text & "6" End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
TextBox1.Text = TextBox1.Text & "7" End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
TextBox1.Text = TextBox1.Text & "8" End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
TextBox1.Text = TextBox1.Text & "9" End Sub
Private Sub Buttondelete_Click(sender As Object, e As EventArgs) Handles
Buttondelete.Click If TextBox1.TextLength <> 0 Then TextBox1.Text = TextBox1.Text.Remove(TextBox1.TextLength - 1) End If End Sub
Private Sub Buttonreset_Click(sender As Object, e As EventArgs) Handles
Buttonreset.Click TextBox1.Text = "" End Sub
Private Sub Buttontitik_Click(sender As Object, e As EventArgs) Handles
Buttontitik.Click TextBox1.Text = TextBox1.Text & "." End Sub
Private Sub Buttonplus_Click(sender As Object, e As EventArgs) Handles
Buttonplus.Click input_angka = Val(TextBox1.Text) rumus = "+" TextBox1.Text = Nothing End Sub
Private Sub Buttonkurang_Click(sender As Object, e As EventArgs) Handles
Buttonmin.Click input_angka = Val(TextBox1.Text) rumus = "-" TextBox1.Text = Nothing End Sub
Private Sub Buttonbagi_Click(sender As Object, e As EventArgs) Handles
Buttonbagi.Click input_angka = Val(TextBox1.Text) rumus = "/" TextBox1.Text = Nothing End Sub
Private Sub Buttonx_Click(sender As Object, e As EventArgs) Handles Buttonx.Click
input_angka = Val(TextBox1.Text) rumus = "*" TextBox1.Text = Nothing End Sub
Private Sub Buttonpangkat_Click(sender As Object, e As EventArgs) Handles
Buttonpangkat.Click input_angka = Val(TextBox1.Text) rumus = "^" TextBox1.Text = Nothing End Sub
Private Sub Buttonsamadengan_Click(sender As Object, e As EventArgs) Handles
Buttonsamadengan.Click hasil = TextBox1.Text If rumus = "=" Then ElseIf rumus = "+" Then TextBox1.Text = input_angka + hasil ElseIf rumus = "-" Then TextBox1.Text = input_angka - hasil ElseIf rumus = "*" Then TextBox1.Text = input_angka * hasil ElseIf rumus = "/" Then TextBox1.Text = input_angka / hasil ElseIf rumus = "^" Then TextBox1.Text = input_angka ^ hasil ElseIf rumus = "√" Then TextBox1.Text = input_angka ^ (1 / 2) End If End Sub
Private Sub Buttonakar_Click(sender As Object, e As EventArgs) Handles
Buttonakar.Click input_angka = Val(TextBox1.Text) rumus = "√" TextBox1.Text = Nothing End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load