Public Class Form1
    Public Class loanform
        Inherits System.Windows.Forms.Form
        Dim cleardisplay As Boolean
        Dim operand1 As Double
        Dim operand2 As Double
        Dim operator As String

    End Class
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click
        Lbdisplay.Text = ""

    End Sub

    Private Sub digit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1.Click, bt2.Click, bt3.Click, bt4.Click, bt5.Click, bt6.Click, bt7.Click, bt8.Click, bt9.Click, bt0.Click
        If cleardisplay Then
            Lbdisplay.Text = ""
            cleardisplay = False

        End If
        Lbdisplay.Text = Lbdisplay.Text + sender.text
        CType(sender, Button).Text = "1"


    End Sub

    Private Sub bt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt.Click
        If Lbdisplay.Text.IndexOf(".") > 0 Then
            Exit Sub
        Else
            Lbdisplay.Text = Lbdisplay.Text & "."

        End If
    End Sub

    Private Sub btplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btplus.Click
        operand1 = Val(Lbdisplay.Text)
        operator = "+"
        cleardisplay = True

    End Operator

    Private Sub btneg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneg.Click
        operand1 = Val(Lbdisplay.Text)
        operator = "-"
        cleardisplay = True
    End Operator

    Private Sub btstr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btstr.Click
        operand1 = Val(Lbdisplay.Text)
        operator = "*"
        cleardisplay = True
    End Operator

    Private Sub bttaq_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttaq.Click
        operand1 = Val(Lbdisplay.Text)
        operator = "/"
        cleardisplay = True
    End Operator

    Private Sub btequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btequals.Click
        Dim Result As Double



        Operand2 = Val(Lbdisplay.Text)

Select Case Operator

            Case "+"

                Result = Operand1 + Operand2

            Case "-"

                Result = Operand1 - Operand2

            Case "*"

                Result = Operand1 * Operand2

            Case "/"


                If Operand2 <> "0" Then Result = Operand1 / Operand2

        End Select

        Lbdisplay.Text = Result


        ClearDisplay = True
If Operator = "+" Then

            Result = Operand1 + Operand2

ElseIf Operator = "-" Then

            Result = Operand1 - Operand2

ElseIf Operator = "*" Then

            Result = Operand1 * Operand2

ElseIf Operator = "/" Then

            If Operand2 <> "0" Then Result = Operand1 / Operand2

    End Sub
End Class
