You are on page 1of 3

Public Class Form1

Dim x(6) As Single


Dim y(6) As Single
Dim z(6) As Single
Dim s, s1, s2, s3, s4, s5, s6, s7 As Double
Dim aa, bb, c, d, e, f, g, h, i, j, k, l As Double
Dim x1, x2, x3, x4, x1n, x2n, x3n, x4n As Double
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
a.Rows(0).Cells(0).Value = "i"
For i = 1 To 6
a.Rows(i).Cells(0).Value = i - 1
Next
a.Rows(0).Cells(1).Value = "x"
a.Rows(1).Cells(1).Value = 0
a.Rows(2).Cells(1).Value = 2
a.Rows(3).Cells(1).Value = 2.5
a.Rows(4).Cells(1).Value = 1
a.Rows(5).Cells(1).Value = 4
a.Rows(6).Cells(1).Value = 7
a.Rows(0).Cells(2).Value = "y"
a.Rows(1).Cells(2).Value = 0
a.Rows(2).Cells(2).Value = 1
a.Rows(3).Cells(2).Value = 2
a.Rows(4).Cells(2).Value = 3
a.Rows(5).Cells(2).Value = 6
a.Rows(6).Cells(2).Value = 2
a.Rows(0).Cells(3).Value = "z"
a.Rows(1).Cells(3).Value = 5
a.Rows(2).Cells(3).Value = 10
a.Rows(3).Cells(3).Value = 9
a.Rows(4).Cells(3).Value = 0
a.Rows(5).Cells(3).Value = 3
a.Rows(6).Cells(3).Value = 27
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
a.Rows.Add(6)
b.Rows.Add(6)
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
b.Rows(0).Cells(0).Value = 6
x(0) = a.Rows(1).Cells(1).Value
x(1) = a.Rows(2).Cells(1).Value
x(2) = a.Rows(3).Cells(1).Value
x(3) = a.Rows(4).Cells(1).Value
x(4) = a.Rows(5).Cells(1).Value
x(5) = a.Rows(6).Cells(1).Value
y(0) = a.Rows(1).Cells(2).Value
y(1) = a.Rows(2).Cells(2).Value
y(2) = a.Rows(3).Cells(2).Value
y(3) = a.Rows(4).Cells(2).Value
y(4) = a.Rows(5).Cells(2).Value
y(5) = a.Rows(6).Cells(2).Value
z(0) = a.Rows(1).Cells(3).Value
z(1) = a.Rows(2).Cells(3).Value
z(2) = a.Rows(3).Cells(3).Value
z(3) = a.Rows(4).Cells(3).Value
z(4) = a.Rows(5).Cells(3).Value
z(5) = a.Rows(6).Cells(3).Value
For i = 0 To 5
s = s + x(i)
s1 = s1 + y(i)
s2 = s2 + (x(i)) ^ 2
s3 = s3 + x(i) * y(i)
s4 = s4 + y((i)) ^ 2
s5 = s5 + z(i)
s6 = s6 + x(i) * z(i)
s7 = s7 + y(i) * z(i)
Next
b.Rows(1).Cells(0).Value = s
b.Rows(0).Cells(1).Value = s
b.Rows(2).Cells(0).Value = s1
b.Rows(0).Cells(2).Value = s1
b.Rows(1).Cells(1).Value = s2
b.Rows(2).Cells(1).Value = s3
b.Rows(1).Cells(2).Value = s3
b.Rows(2).Cells(2).Value = s4
b.Rows(0).Cells(3).Value = s5
b.Rows(1).Cells(3).Value = s6
b.Rows(2).Cells(3).Value = s7
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
x1 = 0
x2 = 0
x3 = 0

x1n = (b.Rows(0).Cells(3).Value - b.Rows(0).Cells(1).Value * x2 -


b.Rows(0).Cells(2).Value * x3) / b.Rows(0).Cells(0).Value
x2n = (b.Rows(1).Cells(3).Value - b.Rows(1).Cells(0).Value * x1 -
b.Rows(1).Cells(2).Value * x3) / b.Rows(1).Cells(1).Value
x3n = (b.Rows(2).Cells(3).Value - b.Rows(2).Cells(0).Value * x1 -
b.Rows(2).Cells(1).Value * x2) / b.Rows(2).Cells(2).Value

Do Until Math.Abs(x1 - x1n) < 1.0E-18


x1 = x1n
x2 = x2n
x3 = x3n

x1n = (b.Rows(0).Cells(3).Value - b.Rows(0).Cells(1).Value * x2 -


b.Rows(0).Cells(2).Value * x3) / b.Rows(0).Cells(0).Value
x2n = (b.Rows(1).Cells(3).Value - b.Rows(1).Cells(0).Value * x1n -
b.Rows(1).Cells(2).Value * x3) / b.Rows(1).Cells(1).Value
x3n = (b.Rows(2).Cells(3).Value - b.Rows(2).Cells(0).Value * x1n -
b.Rows(2).Cells(1).Value * x2n) / b.Rows(2).Cells(2).Value

Loop
txta0.Text = FormatNumber(x1, 4)
txta1.Text = FormatNumber(x2, 4)
txta2.Text = FormatNumber(x3, 4)

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles


btncalcularz.Click
txtz.Text = txta0.Text + txta1.Text * 3 + txta2.Text * 5
End Sub
End Class

You might also like