Visual Basic 10 Scientific Calculator Code Apr 2026

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

The scientific function buttons ( btnSin , btnCos , btnTan , btnExp , btnLog ) evaluate the corresponding mathematical function using the Math class.

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 btn7_Click(sender As Object, e As EventArgs) Handles btn7.Click txtDisplay.Text &= "7" End Sub

Below is the complete code for the scientific calculator: Private Sub btnLog_Click(sender As Object, e As EventArgs)

Private Function EvaluateExpression(expression As String) As Double Dim dataTable As New System.Data.DataTable() Dim result As Double = 0 Try result = dataTable.Compute(expression, String.Empty) Catch ex As Exception Throw ex End Try Return result End Function End Class

Public Class ScientificCalculator Private Sub btn0_Click(sender As Object, e As EventArgs) Handles btn0.Click txtDisplay.Text &= "0" End Sub Private Sub btnLog_Click(sender As Object

Private Sub btnCos_Click(sender As Object, e As EventArgs) Handles btnCos.Click Try Dim angle As Double = Convert.ToDouble(txtDisplay.Text) Dim result As Double = Math.Cos(angle * Math.PI / 180) txtDisplay.Text = result.ToString() Catch ex As Exception txtDisplay.Text = "Error" End Try End Sub

Private Sub btn4_Click(sender As Object, e As EventArgs) Handles btn4.Click txtDisplay.Text &= "4" End Sub

Schedule Appointment

Fill Details For Consultation