Skip to content

Instantly share code, notes, and snippets.

@MarmaladeKnight
Last active December 12, 2018 20:13
Show Gist options
  • Save MarmaladeKnight/6dd0594e694334fbe9494ea0738cb686 to your computer and use it in GitHub Desktop.
Save MarmaladeKnight/6dd0594e694334fbe9494ea0738cb686 to your computer and use it in GitHub Desktop.
Option Strict On
Imports System.Math
Public Class Form1
Function vvod(ByVal t As TextBox) As Double
Return Val(t.Text)
End Function
Sub vivodlist(ByVal t As String, ByVal lb As ListBox)
lb.Items.Add(t)
End Sub
Public Function fun1(ByVal x As Double, ByVal y As Double) As Double
Return x ^ 2 - 5 * (x ^ 3) + 9 * x + 1.987 - y
End Function
Public Sub Cikl(ByVal a As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double, ByVal h1 As Double, ByVal h2 As Double, ByRef n As Double)
Dim i, j, n1, n2 As Integer
Dim x, y, sum As Double
Dim t As String
n1 = CInt(Fix(b - a) / h1 + 1) : n2 = CInt(Fix(d - c) / h2 + 1)
x = a
sum = 0
n = 0
For i = 1 To n1
y = b
For j = 1 To n2
If (fun1(x, y) > 0) Then
sum = sum + fun1(x, y)
n = n + 1
End If
If j = 1 Then
t = "x = " + Format(x, "00.000") + Space(5) + "y = " + Format(y, "00.000") + Space(5) + "sum = " + Format(sum, "00.000")
Else
t = Space(21) + Space(5) + "y = " + Format(y, "00.000") + Space(5) + "sum = " + Format(sum, "00.000")
End If
vivodlist(t, ListBox1)
y = y + h2
Next
x = x + h1
Next
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim a, b, c, d, h1, h2, n As Double
a = vvod(TextBox1) : b = vvod(TextBox2)
c = vvod(TextBox3) : d = vvod(TextBox4)
h1 = vvod(TextBox5)
h2 = vvod(TextBox6)
Cikl(a, b, c, d, h1, h2, n)
TextBox7.Text = CStr(n) + Машка какашка
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
End
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment