Home | News | Freeware | Code | About Us | Contact Us | Links
Freeware: Gett'n Jiggy | Lucky Numbers | Text Editor | Graphic Viewer
Description:Simple Calculator much like windows version. I designed it for use in an upcoming project. We are planning to add more functions soon!
Calculator 1.0 View Code or Download it

Top
Option Explicit
Dim TempNum As Variant
Dim TempNum2 As Variant
Dim Last As Integer
Dim Press As String
Private Sub cmdButton_Click(Index As Integer)
If txtCal.Text = "0" Then
txtCal.Text = ""
End If
Select Case Index
Case 0 To 9 'Number Buttons
If Last = 1 Then
txtCal.Text = ""
TempNum2 = TempNum
End If
txtCal.Text = txtCal.Text & Index
Last = 0
Case 10 '+
Call Total
Press = "P"
Case 11 '-
Call Total
Press = "S"
Case 12 '*
Call Total
Press = "M"
Case 13 '/
Call Total
Press = "D"
Case 14 '.
If Last = 1 Then
txtCal.Text = "0"
TempNum2 = TempNum
End If
txtCal.Text = (txtCal.Text) & "."
cmdButton.Item(14).Enabled = False
Last = 0
Case 15 '=
Call Total
Press = ""
Case 16 ' -/+
txtCal.Text = Val(txtCal.Text) * -1
End Select
End Sub
Private Sub cmdClear_Click()
cmdButton.Item(14).Enabled = True
txtCal.Text = "0"
TempNum = 0
TempNum2 = 0
End Sub
Private Sub cmdMore_Click()
If cmdMore.Caption = "&More >>>" Then
cmdMore.Caption = "<<< &Less"
frmCal.Width = 5685
fraMore.Visible = True
Else
cmdMore.Caption = "&More >>>"
frmCal.Width = 2670
End If
End Sub
Private Sub Form_Load()
cmdButton.Item(14).Enabled = True
frmCal.Top = (Screen.Height - frmCal.Height) / 2
frmCal.Left = (Screen.Width - frmCal.Width) / 2
frmCal.Width = 2670
txtCal.Text = "0"
TempNum = 0
TempNum2 = 0
End Sub
Public Sub Total()
cmdButton.Item(14).Enabled = True
TempNum = Val(txtCal.Text)
Last = 1
If Press = "P" Then
TempNum = Val(TempNum) + Val(TempNum2)
ElseIf Press = "S" Then
If TempNum2 <> "0" Then
TempNum = Val(TempNum2) - Val(TempNum)
End If
ElseIf Press = "M" Then
TempNum = Val(TempNum) * Val(TempNum2)
ElseIf Press = "D" Then
TempNum = Val(TempNum2) / Val(TempNum)
End If
txtCal.Text = TempNum
TempNum2 = "0"
End Sub