Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click 'If no other operation button is clicked, store display into variable If (Calculated = False) Then 'Check to see if anything is in the display and convert to double If (tboxDisplay.Text = Nothing) Or (tboxDisplay.Text = "-") Then FirstValue = 0 Else FirstValue = CDbl(tboxDisplay.Text) End If Else 'if another operation was clicked, perform that operation first 'ditto the check/convert If (tboxDisplay.Text = Nothing) Or (tboxDisplay.Text = "-") Then tmpStore = 0 Else tmpStore = CDbl(tboxDisplay.Text) End If FirstValue = Calculations(FirstValue, tmpStore, Operation) End If Operation = "+" Calculated = True tboxDisplay.Text = "" End Sub
So I'm wondering how to prevent the code from executing if the add button, (or any operation button) is clicked again before the user clicks a number button.
The second problem is purely aesthetics and more for my own curiosity. Currently as soon as a user clicks an operation button, the first value is cleared from the display. I know I could probably store that to a secondary display, but I was wondering if there was a way to keep that value or the calculated value in case of multiple operations in the display until a number button is pressed. Again, not a priority, just wondered if/how it would be possible. The code for one of the number buttons is below.
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click 'buttons just append numbers to what is already in the display 'so check if the equal sign was pressed to erase the previous value first If (Reset = True) Then tboxDisplay.Text = "1" Reset = False Else tboxDisplay.Text &= "1" End If End Sub
Any help on this matter is greatly appreciated. Thanks.
- LN

New Topic/Question
Reply




MultiQuote



|