VB icon

4 function Calculator with 8 level memory

Email
Submitted on: 1/1/2015 7:49:00 PM
By: James Bergeron (from psc cd)  
Level: Not Given
User Rating: By 2 Users
Compatibility: VB 5.0, VB 6.0
Views: 1420
 
     This is a 4 function calculator with 8 - level memory, it performs calculations
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :4 function Calculator with 8 level memory
'**************************************
		
		NONE
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: 4 function Calculator with 8 level memory
' Description:This is a 4 function calculator with 8 - level memory, it performs calculations
' By: James Bergeron (from psc cd)
'
' Returns:Values you calculated
'
' Assumes:Nothing, it works nicely
'
' Side Effects:None, I hope :)
'**************************************

Dim calcarray(0 To 3) As Double
Dim holder As Integer
Dim operation As Integer
Dim decicount As Integer
Dim newnum As Integer
Dim clearcount As Integer
Dim memstorebut(1 To 8) As Double
Dim location As Single
Private Sub clear_Click()
 If clearcount = 0 Then
 txtcal.Text = ""
 clearcount = 1
 Else
 calcarray(0) = 0
 clearcount = 0
 End If
 decicount = 0
End Sub
Private Sub cmdInfo_Click()
Dim Sure As String
Sure = "Created By James Bergeron, For more info e-mail berg0036@algonquinc.on.ca"
Rem Get results from the button click (action)
ButtonClicked = MsgBox(Sure, 0 + 256 + 32, "Info")
End Sub
Private Sub decimal_Click()
clearcount = 0
If decicount = 0 Then
txtcal.Text = txtcal.Text + decimal.Caption
decicount = 1
Else
txtcal.Text = txtcal.Text
End If
End Sub
Private Sub digit_Click(Index As Integer)
If newnum = 1 Then
 txtcal.Text = ""
 txtcal.Text = txtcal.Text + digit(Index).Caption
 calcarray(holder) = txtcal.Text
 newnum = 0
Else
txtcal.Text = txtcal.Text + digit(Index).Caption
calcarray(holder) = txtcal.Text
End If
clearcount = 0
End Sub
Private Sub equal_Click()
Select Case operation
Case 1
 txtcal.Text = calcarray(holder - 1) + calcarray(holder)
 calcarray(0) = txtcal.Text
Case 2
 txtcal.Text = calcarray(holder - 1) - calcarray(holder)
 calcarray(0) = txtcal.Text
Case 3
 txtcal.Text = calcarray(holder - 1) * calcarray(holder)
 calcarray(0) = txtcal.Text
Case 4
 If calcarray(holder) = 0 Then
 txtcal.Text = "Error, can't divide by 0"
 Else
 txtcal.Text = calcarray(holder - 1) / calcarray(holder)
 calcarray(0) = txtcal.Text
 End If
Case Else
txtcal.Text = txtcal.Text
End Select
operation = 5
holder = 0
decicount = 0
newnum = 1
clearcount = 0
End Sub
Private Sub Form_Load()
operation = 0
location = 0
decicount = 0
End Sub
Private Sub memclear_Click()
clearcount = 0
For i = 1 To 8
memstorebut(i) = 0
Next i
location = 0
End Sub
Private Sub memrecall_Click()
clearcount = 0
newnum = 1
If location >= 1 Then
txtcal.Text = memstorebut(location)
calcarray(holder) = memstorebut(location)
memstorebut(location) = 0
location = location - 1
End If
End Sub
Private Sub memstore_Click()
clearcount = 0
If location <= 7 And txtcal.Text > "" Then
location = location + 1
memstorebut(location) = txtcal.Text
End If
End Sub
Private Sub mult_Click()
Call equal_Click
holder = holder + 1
operation = 3
End Sub
Private Sub plus_Click()
 Call equal_Click
 holder = holder + 1
 operation = 1
End Sub
Private Sub div_Click()
Call equal_Click
holder = holder + 1
operation = 4
End Sub
Private Sub sub_Click()
Call equal_Click
holder = holder + 1
operation = 2
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.