Public choice As String
Public current As Double
Public prev As Double
Public counter As Integer
Private Sub ac_Click()
Text1.Text = ""
prev = current = 0
dz.Visible = False
asterisk.Enabled = False
equal.Enabled = False
expo.Enabled = False
logn.Enabled = False
logten.Enabled = False
minus.Enabled = False
plus.Enabled = False
sign.Enabled = False
slash.Enabled = False
sroot.Enabled = False
cosine.Enabled = False
sine.Enabled = False
tangent.Enabled = False
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
End Sub
Private Sub asterisk_Click()
Text1.Text = ""
choice = "*"
prev = current
current = 0
End Sub
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Command1(Index).Caption
current = Text1.Text
asterisk.Enabled = True
equal.Enabled = True
expo.Enabled = True
logn.Enabled = True
logten.Enabled = True
minus.Enabled = True
plus.Enabled = True
sign.Enabled = True
slash.Enabled = True
sroot.Enabled = True
tangent.Enabled = True
cosine.Enabled = True
sine.Enabled = True
End Sub
Private Sub cosine_Click()
Text1.Text = Cos(current * 3.14159265358979 / 180)
current = Cos(current * 3.14159265358979 / 180)
End Sub
Private Sub equal_Click()
If choice = "+" Then
current = prev + current
Text1.Text = current
ElseIf choice = "-" Then
current = prev - current
Text1.Text = current
ElseIf choice = "*" Then
current = prev * current
Text1.Text = current
ElseIf choice = "/" And current <> 0 Then
current = prev / current
Text1.Text = current
Else
Text1.Text = "Press AC to continue"
dz.Visible = True
dz.Caption = "Division by ZERO"
End If
If current < 0 Then
sroot.Enabled = False
Else
sroot.Enabled = True
End If
'asterisk.Enabled = False
'equal.Enabled = False
'expo.Enabled = False
'logn.Enabled = False
'logten.Enabled = False
'minus.Enabled = False
'plus.Enabled = False
'sign.Enabled = False
'slash.Enabled = False
'sroot.Enabled = False
'sine.Enabled = False
'cosine.Enabled = False
'tangent.Enabled = False
'invsine.Visible = False
'invcos.Visible = False
'invtan.Visible = False
'expo.Visible = False
End Sub
Private Sub exit_Click()
Unload Form1
End
End Sub
Private Sub expo_Click()
Text1.Text = Exp(current)
current = Exp(current)
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub expo10_Click()
Dim i As Integer
Dim j As Double
j = current
current = 1
For i = 1 To j Step 1
current = current * 10
Next i
Text1.Text = current
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub Form_Click()
Text1.Text = ""
dz.Visible = False
asterisk.Enabled = False
equal.Enabled = False
expo.Enabled = False
expo10.Enabled = False
logn.Enabled = False
logten.Enabled = False
minus.Enabled = False
plus.Enabled = False
sign.Enabled = False
slash.Enabled = False
sroot.Enabled = False
cosine.Enabled = False
sine.Enabled = False
tangent.Enabled = False
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub Form_Load()
Form1.Width = 4830
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim value As Integer
value = MsgBox("This Calculator was created for scientific calculations, u can do any modification to ur requirements", vbInformation, "About")
End Sub
Private Sub invcos_Click()
Dim temp As Double
temp = current * 3.14159265358979 / 180
If (temp <= 1 And temp >= -1) Then
Text1.Text = 1 / Cos(temp)
current = 1 / Cos(temp)
End If
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub invsine_Click()
Dim temp As Double
temp = current * 3.14159265358979 / 180
If (temp <= 1 And temp >= -1) Then
Text1.Text = 1 / Sin(temp)
current = 1 / Sin(temp)
End If
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub invtan_Click()
Text1.Text = 1 / Tan(current * 3.14159265358979 / 180)
current = 1 / Tan(current * 3.14159265358979 / 180)
invsine.Visible = False
invcos.Visible = False
invtan.Visible = False
expo.Visible = False
expo10.Visible = False
End Sub
Private Sub logn_Click()
Text1.Text = Log(current)
current = Log(current)
End Sub
Private Sub logten_Click()
Text1.Text = Log(current) / Log(10)
current = Log(current) / Log(10)
End Sub
Private Sub mode_MouseDown(Button As Integer, shift As Integer, X As Single, Y As Single)
counter = counter + 1
If counter > 2 Then
counter = 1
End If
If counter = 2 Then
displaylb.Caption = "Normal Calculator"
displaylb.ForeColor = &HFFC0C0
Form1.Width = 4830
sine.Visible = False
cosine.Visible = False
tangent.Visible = False
logn.Visible = False
logten.Visible = False
random.Enabled = False
random.Visible = False
shiftb.Visible = False
recall.Visible = False
Else
displaylb.Caption = " Scientific Calculator"
displaylb.ForeColor = &HC0&
Form1.Width = 5670
sine.Visible = True
cosine.Visible = True
tangent.Visible = True
logn.Visible = True
logten.Visible = True
random.Enabled = True
random.Visible = True
shiftb.Visible = True
recall.Visible = True
End If
End Sub
Private Sub point_Click()
If Text1.Text = "" Then
Text1.Text = "0."
Else
Text1.Text = Text1.Text & "."
End If
End Sub
Private Sub random_Click()
Text1.Text = (2.1021020134 * Rnd + 1)
End Sub
Private Sub recall_Click()
Text1.Text = current
End Sub
Private Sub shiftb_Click()
invsine.Visible = True
invcos.Visible = True
invtan.Visible = True
expo.Visible = True
expo10.Visible = True
If Text1.Text <= 1 And Text1.Text >= -1 Then
invsine.Enabled = True
invcos.Enabled = True
End If
invtan.Enabled = True
expo.Enabled = True
expo10.Enabled = True
End Sub
Private Sub sign_Click()
If current < 0 Then
Text1.Text = -current
current = -current
Else
Text1.Text = "-" & Text1.Text
current = -current
End If
If current < 0 Then
sroot.Enabled = False
Else
sroot.Enabled = True
End If
End Sub
Private Sub minus_Click()
Text1.Text = ""
choice = "-"
prev = current
current = 0
End Sub
Private Sub plus_Click()
Text1.Text = ""
choice = "+"
prev = current
current = 0
End Sub
Private Sub sine_Click()
Text1.Text = Sin(current * 3.14159265358979 / 180)
current = Sin(current * 3.14159265358979 / 180)
End Sub
Private Sub slash_Click()
Text1.Text = ""
choice = "/"
prev = current
current = 0
End Sub
Private Sub sroot_Click()
Text1.Text = Sqr(current)
current = Sqr(current)
End Sub
Private Sub tangent_Click()
Text1.Text = Tan(current * 3.14159265358979 / 180)
current = Tan(current * 3.14159265358979 / 180)
End Sub