I'm making a basic calculator, so far I have programmed the addition, subtraction, multiplication and division without any problems. I want to add a memory, memory recall and memory clear button but I'm not sure how to go about them.
Here is the code I have for the other buttons so far.
Could somebody give me the code for the memory buttons?Code:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num1, num2, ans Try num1 = Val(TextBox1.Text) num2 = Val(TextBox2.Text) ans = num1 + num2 MessageBox.Show(ans) Catch ex As Exception MessageBox.Show(Err.Description) End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim num1, num2, ans Try num1 = Val(TextBox1.Text) num2 = Val(TextBox2.Text) ans = num1 - num2 MessageBox.Show(ans) Catch ex As Exception MessageBox.Show(Err.Description) End Try End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim num1, num2, ans Try num1 = Val(TextBox1.Text) num2 = Val(TextBox2.Text) ans = num1 * num2 MessageBox.Show(ans) Catch ex As Exception MessageBox.Show(Err.Description) End Try End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim num1, num2, ans Try num1 = Val(TextBox1.Text) num2 = Val(TextBox2.Text) ans = num1 / num2 MessageBox.Show(ans) Catch ex As Exception MessageBox.Show(Err.Description) End Try End Sub End Class
(Thanks)




Reply With Quote