I was wondering the best way to implement a square root button.
Below has everything from 0-9, the four functions, and a decimal and clear function.
Dim valueOne As Single
Dim valueTwo As Single
Dim operation As Integer
Dim answer As Single
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TextBoxDisplay.Text += "1"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.TextBoxDisplay.Text += "2"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.TextBoxDisplay.Text += "3"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.TextBoxDisplay.Text += "4"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.TextBoxDisplay.Text += "5"
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.TextBoxDisplay.Text += "6"
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Me.TextBoxDisplay.Text += "7"
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Me.TextBoxDisplay.Text += "8"
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Me.TextBoxDisplay.Text += "9"
End Sub
Private Sub Button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.Click
Me.TextBoxDisplay.Text += "0"
End Sub
Private Sub ButtonDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDecimal.Click
Me.TextBoxDisplay.Text += "."
Me.ButtonDecimal.Enabled = False
End Sub
Friend WithEvents ButtonClear As System.Windows.Forms.Button
Private Sub ButtonClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonClear.Click
Me.TextBoxDisplay.Text = " "
Me.ButtonDecimal.Enabled = True
End Sub
Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAdd.Click
Me.ButtonDecimal.Enabled = True
operation = 1
valueOne = Val(TextBoxDisplay.Text)
Me.TextBoxDisplay.Text = " "
End Sub
Private Sub ButtonSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSubtract.Click
Me.ButtonDecimal.Enabled = True
operation = 2
valueOne = Val(TextBoxDisplay.Text)
Me.TextBoxDisplay.Text = " "
End Sub
Private Sub ButtonMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMultiply.Click
Me.ButtonDecimal.Enabled = True
operation = 3
valueOne = Val(TextBoxDisplay.Text)
Me.TextBoxDisplay.Text = " "
End Sub
Private Sub ButtonDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDivide.Click
Me.ButtonDecimal.Enabled = True
operation = 4
valueOne = Val(TextBoxDisplay.Text)
Me.TextBoxDisplay.Text = " "
End Sub
Private Sub ButtonCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCalc.Click
valueTwo = Val(TextBoxDisplay.Text)
Me.ButtonDecimal.Enabled = False
Select Case operation
Case 1
answer = valueOne + valueTwo
Case 2
answer = valueOne - valueTwo
Case 3
answer = valueOne * valueTwo
Case 4
answer = valueOne / valueTwo
Case Else
Me.TextBoxDisplay.Text = "Error"
End Select
Me.TextBoxDisplay.Text = answer
End Sub