Visual Basic 10 Scientific Calculator Code May 2026
The scientific calculator will have a user-friendly interface with buttons for digits 0-9, four arithmetic operations (+, -, *, /), and various scientific functions (sin, cos, tan, exp, log, etc.). The calculator will display the results in a text box.
Private Sub btn1_Click(sender As Object, e As EventArgs) Handles btn1.Click txtDisplay.Text &= "1" End Sub Visual Basic 10 Scientific Calculator Code
Private Sub btnTan_Click(sender As Object, e As EventArgs) Handles btnTan.Click Try Dim angle As Double = Convert.ToDouble(txtDisplay.Text) Dim result As Double = Math.Tan(angle * Math.PI / 180) txtDisplay.Text = result.ToString() Catch ex As Exception txtDisplay.Text = "Error" End Try End Sub four arithmetic operations (+
Private Sub btn9_Click(sender As Object, e As EventArgs) Handles btn9.Click txtDisplay.Text &= "9" End Sub and various scientific functions (sin
Private Sub btnLog_Click(sender As Object, e As EventArgs) Handles btnLog.Click Try Dim result As Double = Math.Log(Convert.ToDouble(txtDisplay.Text)) txtDisplay.Text = result.ToString() Catch ex As Exception txtDisplay.Text = "Error" End Try End Sub
Private Sub btnSubtract_Click(sender As Object, e As EventArgs) Handles btnSubtract.Click txtDisplay.Text &= "-" End Sub