Рет қаралды 2,778
CODE FOR J.J CALCULATOR ✨
Option Explicit
Dim var1, var2 As Double
Dim opern As String
Private Sub add_Click(Index As Integer)
var1 = Val(display.Text)
opern = "+"
display.Text = ""
End Sub
Private Sub clear_Click(Index As Integer)
display.Text = ""
End Sub
Private Sub digits_click(Index As Integer)
display.Text = display.Text + digits(Index).Caption
End Sub
Private Sub divide_Click(Index As Integer)
var1 = Val(display.Text)
opern = "/"
display.Text = ""
End Sub
Private Sub dot_Click(Index As Integer)
display.Text = display.Text + "."
End Sub
Private Sub equal_Click(Index As Integer)
var2 = Val(display.Text)
Select Case opern
Case "+": display.Text = var1 + var2
Case "-": display.Text = var1 - var2
Case "/": display.Text = var1 / var2
Case "*": display.Text = var1 * var2
Case "%": display.Text = var1 * 1 / 100
End Select
End Sub
Private Sub multiple_Click(Index As Integer)
var1 = Val(display.Text)
opern = "*"
display.Text = ""
End Sub
Private Sub percentage_Click(Index As Integer)
var1 = Val(display.Text)
opern = "%"
End Sub
Private Sub subtract_Click(Index As Integer)
var1 = Val(display.Text)
opern = "-"
display.Text = ""
End Sub