Option
Explicit On
Option
Strict On
Imports
System.Math
Public Class Form1
'процедура-подпрограмма вычисляет z при 3-ом
условии
Sub usl_3(ByVal x1 As Single, ByVal y1 As Single, ByVal a1 As Single, ByRef z As Single)
z = CSng(x1 +
Sqrt(a1))
vivod(z, TextBox4)
End Sub
'процедура-подпрограмма вычисляет min при 1-ом условии
Sub usl_1(ByVal x1 As Single, ByVal y1 As Single, ByVal a1 As Single, ByRef z As Single)
Dim min As Single
min = a1 * x1
If min
> y1 Then
min = y1
If min
> Sin(x1 * y1) Then
min = CSng(Sin(x1
* y1))
End If
End If
vivod(min, TextBox4)
End Sub
'процедура-подпрограмма вычисляет max при
3-ем условии
Sub usl_2(ByVal x1 As Single, ByVal y1 As Single, ByVal a1 As Single, ByRef z As Single)
Dim max As Single
max = CSng(Exp(x1))
If max
< (x1 + a1 * y1) Then
max = (x1 + a1 * y1)
End If
vivod(max, TextBox4)
End Sub
'процедура-подпрограмма выполянет вывод
переменной в TextBox
Sub vivod(ByVal W As Single, ByRef T As TextBox)
T.Text = CStr(W)
End Sub
'процедура-Function выполняет ввод переменной в TextBox
Function vvod(ByVal T As TextBox) As Single
Return CSng(Val(T.Text))
End Function
'///////////////////////////////////////////////////////////////////
Private Sub
Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim x As Single
Dim y As Single
Dim a As Single
Dim z As Single
x = vvod(TextBox1)
y = vvod(TextBox2)
a = vvod(TextBox3)
If y >
2 And x > 0 Then
usl_1(x, y, a, z)
MsgBox("расчет
прошел по условию Y>2 и X>0")
ElseIf y
<= 2 And x < 0 Then
usl_2(x, y, a, z)
MsgBox("расчет
прошел по условию Y<=2
и X<0")
Else
usl_3(x, y, a, z)
MsgBox("расчет
прошел по условию в противном случае")
End If
End Sub
Private Sub
Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
End Sub
Private Sub
Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Application.Exit()
End Sub
End Class
Комментариев нет:
Отправить комментарий