среда, 24 декабря 2014 г.

3 лабораторная код 2

Option Strict On
Option Explicit On
Imports System.Math


Public Class Form1


    Function vvod(ByVal T As TextBox) As Single

        Return CSng(Val(T.Text))

    End Function

    Sub vivod(ByVal Z As Double, ByVal T As TextBox)

        T.Text = CStr(Z)

    End Sub


    Function corner(ByVal side1 As Double, ByVal side2 As Double, ByVal side3 As Double) As Double

        Return (Acos((side1 ^ 2 + side2 ^ 2 - side3 ^ 2) / (2 * side1 * side2)))

    End Function



    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        'Задание типов данных
        Dim a As Double
        Dim b As Double
        Dim c As Double

        Dim alpha As Double
        Dim beta As Double
        Dim gamma As Double

        Dim sum As Double
        'ввод исходных данных

        a = vvod(TextBox1)
        b = vvod(TextBox2)
        c = vvod(TextBox3)

        'вычисления углов треугольника

        alpha = corner(b, c, a)
        beta = corner(a, c, b)
        gamma = corner(b, a, c)
        sum = alpha + beta + gamma

        'вывод результатов на экран

        vivod(alpha, TextBox4)
        vivod(beta, TextBox5)
        vivod(gamma, TextBox6)
        vivod(sum, TextBox7)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Очистка всех TextBox
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox7.Clear()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Application.Exit()

    End Sub





End Class

Комментариев нет:

Отправить комментарий