Bagi seorang pemula seperti saya, dapat membuat suatu program kalkulator adalah suatu keharusan, demakin banyak fungsi atau tombol-tombol yang tersedia maka semakin bagus.
Dim tanda, unik As Integer
Text1.Text = Text1.Text & "1"
If tanda > 0 Then
Text3.Text = Text3.Text & "1"
End If
End Sub
Text1.Text = Text1.Text & "0"
If tanda > 0 Then
Text3.Text = Text3.Text & "0"
End If
End Sub
If tanda > 0 Then
Text1.Text = Text1.Text & "-"
unik = 1 'VARIABLE unik 1 UNTUK bentuk negatif
Exit Sub
End If
Text1.Text = Text1.Text * -1
End Sub
Text1.Text = Text1.Text & "."
unik = 2 'VARIABLE unik 2 UNTUK DESIMAL
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 1
Text1.Text = Text1.Text & "+"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 1
Text1.Text = Text1.Text & "+"
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 2
Text1.Text = Text1.Text & "-"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 2
Text1.Text = Text1.Text & "-"
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 3
Text1.Text = Text1.Text & "x"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 3
Text1.Text = Text1.Text & "x"
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 4
text1.Text = Text1.Text & "/"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 4
Text1.Text = Text1.Text & "/"
End Sub
nilai2 = Text3.Text
If unik = 1 Then
nilai2 = nilai2 * -1
End If
Case 1
hasil = (nilai1 - 1) + (nilai2 + 1) ‘PENJUMLAHAN
Case 2
hasil = nilai1 - nilai2 ‘PENGURANGAN
Case 3
hasil = nilai1 * nilai2 ‘PERKALIAN
Case 4
If nilai2 = 0 Then
MsgBox " TERJADI ERROR, PEMBAGIAN DENGAN O ", vbCritical, "Error"
Text1.Text = ""
Exit Sub
End If
hasil = nilai1 / nilai2 ‘PEMBAGIAN
Case 5
hasil = nilai1 * nilai1 ‘KUADRAT
Case 6
hasil = nilai1 ^ nilai2 ‘PANGKAT n
Case 7
hasil = nilai2
Case 8
hasil = Sin(CDbl(nilai2))
Case 9
hasil = Cos(CDbl(nilai2))
Case 10
hasil = Tan(CDbl(nilai2))
Case 11
If nilai2 < 0 Then
MsgBox "TIDAK DAPAT MENGHITUNG NILAI AKAR DARI BILANGAN NEGATIF ", vbInformation, "PEMBERITAHUAN ERROR"
Exit Sub
End If
hasil = Sqr(nilai2)
End Select
If unik = 2 Then
hasil = hasil * 0.1
End If
tanda = 50
Text3.Text = ""
Text2.Text = hasil
End Sub
tanda = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
MsgBox "Coded by : T. Erick Sitorus " & vbCrLf & "Known As : WONDERKID ", vbInformation, “KALKULATOR INI"
End
End Sub
Text1.Text = Text1.Text & "2"
If tanda > 0 Then
Text3.Text = Text3.Text & "2"
End If
End Sub
tanda = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 5
Text1.Text = Text1.Text & "^2"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 5
Text1.Text = Text1.Text & "^2"
End Sub
If tanda = 50 Then
Text1.Text = hasil
nilai1 = Text2.Text
tanda = 6
Text1.Text = Text1.Text & "^"
Exit Sub
End If
nilai1 = Text1.Text
tanda = 6
text1.Text = Text1.Text & "^"
End Sub
MsgBox "THIS PROGRAM WAS CREATED BY T. ERICK SITORUS, THIS PROGRAM IS MADE ONLY TO CALCULATE SIMPLE MATHEMATIC OPERATION", vbCritical, "About This Program"
End Sub
Text3.Text = Text3.Text * 0.01
Text1.Text = Text1.Text & "%"
End Sub
Text1.Text = hasil
nilai1 = Text1.Text
tanda = 7
Text1.Text = Text1.Text & "!"
For a = nilai1 - 1 To 1 Step -1
nilai1 = nilai1 * a
Next a
Text3.Text = nilai1
End Sub
Text1.Text = ""
tanda = 8
Text1.Text = Text1.Text & "sin"
End Sub
Text1.Text = ""
tanda = 9
Text1.Text = Text1.Text & "cos"
End Sub
Text1.Text = ""
tanda = 10
Text1.Text = Text1.Text & "tan"
End Sub
tanda = 11
Text1.Text = Text1.Text & "sqr"
End Sub
Text1.Text = Text1.Text & "3"
If tanda > 0 Then
Text3.Text = Text3.Text & "3"
End If
End Sub
If Text1.Text = "" Then
MsgBox "LAYAR SUDAH KOSONG ", vbInformation, "INFO"
Exit Sub
End If
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
If tanda > 0 Then
tanda = 0
End If
End Sub
Text1.Text = Text1.Text & "4"
If tanda > 0 Then
Text3.Text = Text3.Text & "4"
End If
End Sub
Text1.Text = Text1.Text & "5"
If tanda > 0 Then
Text3.Text = Text3.Text & "5"
End If
End Sub
Text1.Text = Text1.Text & "6"
If tanda > 0 Then
Text3.Text = Text3.Text & "6"
End If
End Sub
Text1.Text = Text1.Text & "7"
If tanda > 0 Then
Text3.Text = Text3.Text & "7"
End If
End Sub
Text1.Text = Text1.Text & "8"
If tanda > 0 Then
Text3.Text = Text3.Text & "8"
End If
End Sub
Text1.Text = Text1.Text & "9"
If tanda > 0 Then
Text3.Text = Text3.Text & "9"
End If
End Sub
tanda = 0
End Sub