I want to write a web calculator in asp.net with vb.
I am a beginner in vb.net and asp.net and i want to learn both of them with practice
please help me i really need you friends
thanks:confused:

Imports System.Math

Public Class calculator

    Dim cleardisplay As Boolean
    Dim operand1 As Double
    Dim operand2 As Double
    Dim Operator1 As String

    Private Sub Digit_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btn1.Click, btn2.Click, _
            btn3.Click, btn4.Click, btn5.Click, btn6.Click, _
            btn7.Click, btn8.Click, btn9.Click, btn0.Click
        If cleardisplay Then
            txtDisplay.Text = ""
            cleardisplay = False
        End If
        txtDisplay.Text = txtDisplay.Text + sender.Text
    End Sub

    Private Sub btnPeriod_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPeriod.Click
        If txtDisplay.Text.IndexOf(".") > 0 Then
            Exit Sub
        Else
            txtDisplay.Text = txtDisplay.Text & "."
        End If
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtDisplay.Text = ""
    End Sub

    Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click

        Dim result As Double
        operand2 = Val(txtDisplay.Text)
        Select Case Operator1
            Case "+"
                result = operand1 + operand2
            Case "-"
                result = operand1 - operand2
            Case "*"
                result = operand1 * operand2
            Case "/"
                If operand2 <> "0" Then result = operand1 / operand2
        End Select
        txtDisplay.Text = result
        cleardisplay = True
    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        operand1 = Val(txtDisplay.Text)
        Operator1 = "+"
        cleardisplay = True
    End Sub

    Private Sub btnPrefix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrefix.Click
        txtDisplay.Text = -Val(txtDisplay.Text)
        cleardisplay = True
    End Sub

    Private Sub btnInvers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInverse.Click
        If Val(txtDisplay.Text) <> 0 Then txtDisplay.Text = 1 / Val(txtDisplay.Text)
        cleardisplay = True
    End Sub

    Private Sub btnTimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimes.Click
        operand1 = Val(txtDisplay.Text)
        Operator1 = "*"
        cleardisplay = True
    End Sub

    Private Sub btnMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMinus.Click
        operand1 = Val(txtDisplay.Text)
        Operator1 = "-"
        cleardisplay = True
    End Sub

    Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
        operand1 = Val(txtDisplay.Text)
        Operator1 = "/"
        cleardisplay = True
    End Sub

    Private Sub btnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLog.Click
        If Val(txtDisplay.Text) < 0 Then
            MsgBox("Can’t calculate the logarithm of a negative number")
        Else
            txtDisplay.Text = Math.Log(txtDisplay.Text)
        End If
        cleardisplay = True
    End Sub

    Private Sub btnCos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCos.Click
        txtDisplay.Text = Math.Cos(Val(txtDisplay.Text))
    End Sub

    Private Sub btnSine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSine.Click
        txtDisplay.Text = Math.Sin(Val(txtDisplay.Text))
    End Sub

    Private Sub btnTan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTan.Click
        txtDisplay.Text = Math.Tan(Val(txtDisplay.Text))
    End Sub

    Private Sub btnSquareRoot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSquareRoot.Click
        txtDisplay.Text = Math.Sqrt(Val(txtDisplay.Text))
    End Sub

    Private Sub btnSquare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSquare.Click
        operand1 = Val(txtDisplay.Text) * Val(txtDisplay.Text)
        txtDisplay.Text = operand1
        cleardisplay = True
    End Sub


    Private Sub btnRoot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRoot.Click
        
    End Sub

    Private Sub btnAbsolute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbsolute.Click
        txtDisplay.Text = Math.Abs(Val(txtDisplay.Text))
    End Sub

    Private Sub txtDisplay_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDisplay.TextChanged
        If Not IsNumeric(txtDisplay.Text) Then
            txtDisplay.Text = ""
        End If
    End Sub

    Private Sub btnExponent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExponent.Click
        txtDisplay.Text = Math.Exp(Val(txtDisplay.Text))
    End Sub

    Private Sub btnLn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLn.Click
        txtDisplay.Text = Math.Log10(Val(txtDisplay.Text))
    End Sub

End Class
commented: Handing someone a completed program is not helping them. -3

chibex64
thanks so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.