Public Class Form1
    Dim znak As String
    Dim Vvodim As Boolean = True
    Dim val1, val2 As Double

    Private Sub Digit_Click(ByVal sender As System.Object,
             ByVal e As System.EventArgs) Handles Button10.Click,
                     Button1.Click, Button2.Click, Button3.Click,
                     Button4.Click, Button5.Click, Button6.Click,
        Button7.Click, Button8.Click, Button9.Click

        Beep()
        Dim Digit As String = CType(sender, Button).TabIndex


        If Vvodim = True Then TextBox1.Text = Digit _
                                           : Vvodim = False : Exit Sub

        If Vvodim = False Then TextBox1.Text =
                                                 TextBox1.Text & Digit


    End Sub

    Private Sub TextBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter
        Button1.Focus()
    End Sub

    Private Sub Func_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "+"
        Vvodim = True

    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        Beep()
        Dim result As Double
        val2 = Double.Parse(TextBox1.Text)


        If znak = "+" Then result = val1 + val2
        If znak = "-" Then result = val1 - val2
        If znak = "*" Then result = val1 * val2
        If znak = "/" Then result = val1 / val2
        If znak = "Sin" Then result = Math.Sin(val1)
        If znak = "cos" Then result = Math.Cos(Val(val1))
        If znak = "Pro" Then result = Val(val1) * Val(0.01)
        If znak = "kor" Then result = Math.Sqrt(Val(val1))

        TextBox1.Text = result.ToString
        val1 = result : Vvodim = True
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "-"
        Vvodim = True
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "*"
        Vvodim = True
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "/"
        Vvodim = True
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "Sin"
        Vvodim = True
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "kor"
        Vvodim = True
    End Sub

    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        Beep()
        val1 = Single.Parse(TextBox1.Text)
        znak = "cos"
        Vvodim = True
    End Sub

    Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
        Beep()
        TextBox1.Text = Math.PI
    End Sub

    Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click
        Beep()
        Dim Dig As String = CType(sender, Button).Text


        If Vvodim = True Then TextBox1.Text = Dig _
                                             : Vvodim = False : Exit Sub

        If Vvodim = False Then TextBox1.Text =
                                                 TextBox1.Text & Dig

    End Sub

    Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click
        Beep()
        val1 = Double.Parse(TextBox1.Text)
        znak = "Pro"
        Vvodim = True
    End Sub

    Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
        val1 = TextBox1.Text
        TextBox1.Text = ("-" & val1)
        Button27.Visible = False
        Button28.Visible = True
    End Sub

    Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button28.Click
        Beep()
        val1 = TextBox1.Text
        TextBox1.Text = (" " & val1)
        Button28.Visible = False
        Button27.Visible = True
    End Sub

    Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
        Beep()
        TextBox1.Text = "0"
        Vvodim = True
        znak = ""
    End Sub

    Private Sub КопироватьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles КопироватьToolStripMenuItem.Click
        TextBox1.SelectAll()
        TextBox1.Copy()
    End Sub
    Private Sub ВставитьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ВставитьToolStripMenuItem.Click
        TextBox1.Text = " "
        TextBox1.Paste()
    End Sub

    Private Sub ОчиститьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОчиститьToolStripMenuItem.Click
        TextBox1.Clear()
    End Sub

    Private Sub ОтменитьПравкуToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОтменитьПравкуToolStripMenuItem.Click
        TextBox1.Undo()
    End Sub

    Private Sub СоздательToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles СоздательToolStripMenuItem.Click
        Process.Start("iexplore", "http://ds-release.ru")
    End Sub

    Private Sub ПартнерToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ПартнерToolStripMenuItem.Click
        Process.Start("iexplore", "http://vbbook.ru")
    End Sub

    Private Sub ОПрограммеToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОПрограммеToolStripMenuItem.Click
        Form2.Show()
    End Sub
End Class
