SIMPLE CALCULATOR
Dim d As Double
Dim i As Integer
Dim s As String
Private Sub Command1_Click(Index As Integer)
Image2.Enabled = True
Select Case Index
Case 0
Text1.Enabled = True
Text1.SetFocus
For i = 1 To 26
Command1(i).Enabled = True
Next i
Command1(0).Enabled = False
Case 1
End
Case 2
Text1.Text = ""
Text1.SetFocus
Case 3 To 13
Text1.Text = Text1.Text + (Command1 (Index).Caption)
Case 14 To 17
d = Text1.Text
Text1.Text = ""
s = Command1(Index).Caption
Case 18
If s = "+" Then
Text1.Text = Val(d) + Val (Text1.Text)
ElseIf s = "-" Then
Text1.Text = Val(d) - Val(Text1.Text)
ElseIf s = "*" Then
Text1.Text = Val(d) * Val (Text1.Text)
ElseIf s = "/" Then
Text1.Text = Val (d) / Val (Text1.Text)
End If
Case 19
Text1.Text = Round(Sin((Text1.Text) * 3.14 / 180), 2)
Case 20
Text1.Text = Round(Cos((Text1.Text) * 3.14 / 180), 2)
Case 21
If Text1.Text = 90 Then
Text1.Text = "Infinite"
Else
Text1.Text = Round(Tan((Text1.Text) * 3.14 / 180), 2)
End If
Case 22
Text1.Text = Log(Text1.Text) / Log(10)
Case 23
Text1.Text = Sqr(Text1.Text)
Case 24
Text1.Text = Text1.Text * Text1.Text
Case 25
Text1.Text = 1 / Text1.Text
Case 26
Text1.Text = Text1.Text / 100
End Select
End Sub
Private Sub Form_Load()
For i = 1 To 26
Command1(i).Enabled = False
Next i
Text1.Enabled = True
End Sub
OUTPUT:
0 comments
Post a Comment