Hi everyone. I did a super simple calculator with ASP.net with five buttons: add, subtract, multiply, divide, clear. There are five separate functions for each button's click event. For example:
Sub addfunction(ByVal s As Object, ByVal e As EventArgs) If Not IsNumeric(input1.Text) Or Not IsNumeric(input2.Text) Then resultLabel.Text = "You entered an invalid or missing number" Else number1 = Decimal.Parse(input1.Text) number2 = Decimal.Parse(input2.Text) addresult = number1 + number2 resultLabel.Text = addresult.ToString End If <asp:Button ID="addBtn" runat="server" style="z-index: 1; left: 78px; top: 130px; position: absolute; width: 65px" Text="Add" onclick="addfunction" />
How might I be able to combine all 5 of these functions into one? So for example, all the onclicks will refer to the same function, but will somehow be able to determine which button was clicked? I forget a lot of VB.net from a year ago so any help would be great. Thanks!