1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
| Private Sub CommandButton1_Click()
Dim y1, y2, y3, y4, y5 As String
Dim a1, a2, a3, a4, a5 As String
Dim b1, b2, b3, b4, b5 As String
Dim c1, c2, c3, c4, c5 As String
Dim e1, e2, e3, e4, e5 As String
Dim f1, f2, f3, f4, f5 As String
Dim d1, d2, d3, d4, d5 As String
Dim s, s1, s2, s3, s4, s5 As String
Dim n As Integer
n = TextBox11.Text
If n <= 1 Then
MsgBox "Ðàíã ìàòðèöû äîëæåí áûòü 2 è áîëüøå ", vbOKOnly, "Îøèáêà "
End If
If n = 2 Then
y1 = TextBox1.Text
y2 = TextBox2.Text
a1 = Val(Mid(y1, 1, InStr(y1, "x1")))
a2 = Val(Mid(y1, InStr(y1, "x1") + 2, InStr(y1, "x2")))
b1 = Val(Mid(y2, 1, InStr(y2, "x1")))
b2 = Val(Mid(y2, InStr(y2, "x1") + 2, InStr(y2, "x2")))
d1 = TextBox6.Text
d2 = TextBox7.Text
s = a1 * b2 - a2 * b1
Label7.Caption = Format(s, "####.00")
s1 = d1 * b2 - a2 * d2
s2 = a1 * d2 - d1 * b1
Label8.Caption = "x1=" & Format(s1 / s, "####.00")
Label9.Caption = "x2=" & Format(s2 / s, "####.00")
End If
If n = 3 Then
y1 = TextBox1.Text
y2 = TextBox2.Text
y3 = TextBox3.Text
a1 = Val(Mid(y1, 1, InStr(y1, "x1")))
a2 = Val(Mid(y1, InStr(y1, "x1") + 2, InStr(y1, "x2")))
a3 = Val(Mid(y1, InStr(y1, "x2") + 2, InStr(y1, "x3")))
b1 = Val(Mid(y2, 1, InStr(y2, "x1")))
b2 = Val(Mid(y2, InStr(y2, "x1") + 2, InStr(y2, "x2")))
b3 = Val(Mid(y2, InStr(y2, "x2") + 2, InStr(y2, "x3")))
c1 = Val(Mid(y3, 1, InStr(y3, "x1")))
c2 = Val(Mid(y3, InStr(y3, "x1") + 2, InStr(y3, "x2")))
c3 = Val(Mid(y3, InStr(y3, "x2") + 2, InStr(y3, "x3")))
d1 = TextBox6.Text
d2 = TextBox7.Text
d3 = TextBox8.Text
s = det(a1, a2, a3, b1, b2, b3, c1, c2, c3)
Label7.Caption = Format(s, "####.00")
s1 = det(d1, a2, a3, d2, b2, b3, d3, c2, c3)
s2 = det(a1, d1, a3, b1, d2, b3, c1, d3, c3)
s3 = det(a1, a2, d3, b1, b2, d2, c1, c2, d3)
Label8.Caption = "x1=" & Format(s1 / s, "####.00")
Label9.Caption = "x2=" & Format(s2 / s, "####.00")
Label10.Caption = "x3=" & Format(s3 / s, "####.00")
End If
If n = 4 Then
y1 = TextBox1.Text
y2 = TextBox2.Text
y3 = TextBox3.Text
y4 = TextBox4.Text
a1 = Val(Mid(y1, 1, InStr(y1, "x1")))
a2 = Val(Mid(y1, InStr(y1, "x1") + 2, InStr(y1, "x2")))
a3 = Val(Mid(y1, InStr(y1, "x2") + 2, InStr(y1, "x3")))
a4 = Val(Mid(y1, InStr(y1, "x3") + 2, InStr(y1, "x4")))
b1 = Val(Mid(y2, 1, InStr(y2, "x1")))
b2 = Val(Mid(y2, InStr(y2, "x1") + 2, InStr(y2, "x2")))
b3 = Val(Mid(y2, InStr(y2, "x2") + 2, InStr(y2, "x3")))
b4 = Val(Mid(y2, InStr(y2, "x3") + 2, InStr(y2, "x4")))
c1 = Val(Mid(y3, 1, InStr(y3, "x1")))
c2 = Val(Mid(y3, InStr(y3, "x1") + 2, InStr(y3, "x2")))
c3 = Val(Mid(y3, InStr(y3, "x2") + 2, InStr(y3, "x3")))
c4 = Val(Mid(y3, InStr(y3, "x3") + 2, InStr(y3, "x4")))
e1 = Val(Mid(y4, 1, InStr(y4, "x1")))
e2 = Val(Mid(y4, InStr(y4, "x1") + 2, InStr(y4, "x2")))
e3 = Val(Mid(y4, InStr(y4, "x2") + 2, InStr(y4, "x3")))
e4 = Val(Mid(y4, InStr(y4, "x3") + 2, InStr(y4, "x4")))
d1 = TextBox6.Text
d2 = TextBox7.Text
d3 = TextBox8.Text
d4 = TextBox9.Text
s = a1 * (det(b2, b3, b4, c2, c3, c4, e2, e3, e4)) - a2 * (det(b1, b3, b4, c1, c3, c4, e1, e3, e4)) + a3 * (det(b1, b2, b4, c1, c2, c4, e1, e1, e4)) - a4 * (det(b1, b2, b3, c1, c2, c3, e1, e2, e3))
Label7.Caption = Format(s, "####.00")
s1 = d1 * (det(b2, b3, b4, c2, c3, c4, e2, e3, e4)) - a2 * (det(d2, b3, b4, d3, c3, c4, d4, e3, e4)) + a3 * (det(d2, b2, b4, d3, c2, c4, d4, e2, e4)) - a4 * (det(d2, b2, b3, d3, c2, c3, d4, e2, e3))
s2 = a1 * (det(b2, d2, b4, c2, d3, c4, e2, d4, e4)) - d1 * (det(b1, b3, b4, c1, c3, c4, e1, e3, e4)) + a3 * (det(b1, d2, b4, c1, d3, c4, e1, d4, e4)) - a4 * (det(b1, d2, b3, c1, d3, c3, e1, d4, e3))
s3 = a1 * (det(b2, d2, b4, c2, d3, c4, e2, d4, e4)) - a2 * (det(b1, d2, b4, c1, d3, c4, e1, d4, e4)) + d1 * (det(b1, b2, b4, c1, c2, c4, e1, e2, e4)) - a4 * (det(b1, b2, d2, c1, c2, d3, e1, e2, d4))
s4 = a1 * (det(b2, b3, d2, c2, c3, d3, e2, e3, d4)) - a2 * (det(b1, b3, d2, c1, c3, d3, e1, e3, d4)) + a3 * (det(b1, b2, d2, c1, c2, d3, e1, e2, d4)) - d1 * (det(b1, b2, b3, c1, c2, c3, e1, e2, e3))
Label8.Caption = "x1=" & Format(s1 / s, "####.00")
Label9.Caption = "x2=" & Format(s2 / s, "####.00")
Label10.Caption = "x3=" & Format(s3 / s, "####.00")
Label11.Caption = "x4=" & Format(s4 / s, "####.00")
End If
If n = 5 Then
y1 = TextBox1.Text
y2 = TextBox2.Text
y3 = TextBox3.Text
y4 = TextBox4.Text
y5 = TextBox5.Text
a1 = Val(Mid(y1, 1, InStr(y1, "x1")))
a2 = Val(Mid(y1, InStr(y1, "x1") + 2, InStr(y1, "x2")))
a3 = Val(Mid(y1, InStr(y1, "x2") + 2, InStr(y1, "x3")))
a4 = Val(Mid(y1, InStr(y1, "x3") + 2, InStr(y1, "x4")))
a5 = Val(Mid(y1, InStr(y1, "x4") + 2, InStr(y1, "x5")))
b1 = Val(Mid(y2, 1, InStr(y2, "x1")))
b2 = Val(Mid(y2, InStr(y2, "x1") + 2, InStr(y2, "x2")))
b3 = Val(Mid(y2, InStr(y2, "x2") + 2, InStr(y2, "x3")))
b4 = Val(Mid(y2, InStr(y2, "x3") + 2, InStr(y2, "x4")))
b5 = Val(Mid(y2, InStr(y2, "x4") + 2, InStr(y2, "x5")))
c1 = Val(Mid(y3, 1, InStr(y3, "x1")))
c2 = Val(Mid(y3, InStr(y3, "x1") + 2, InStr(y3, "x2")))
c3 = Val(Mid(y3, InStr(y3, "x2") + 2, InStr(y3, "x3")))
c4 = Val(Mid(y3, InStr(y3, "x3") + 2, InStr(y3, "x4")))
c5 = Val(Mid(y3, InStr(y3, "x4") + 2, InStr(y3, "x5")))
e1 = Val(Mid(y4, 1, InStr(y4, "x1")))
e2 = Val(Mid(y4, InStr(y4, "x1") + 2, InStr(y4, "x2")))
e3 = Val(Mid(y4, InStr(y4, "x2") + 2, InStr(y4, "x3")))
e4 = Val(Mid(y4, InStr(y4, "x3") + 2, InStr(y4, "x4")))
e5 = Val(Mid(y4, InStr(y4, "x4") + 2, InStr(y4, "x5")))
f1 = Val(Mid(y5, 1, InStr(y5, "x1")))
f2 = Val(Mid(y5, InStr(y5, "x1") + 2, InStr(y5, "x2")))
f3 = Val(Mid(y5, InStr(y5, "x2") + 2, InStr(y5, "x3")))
f4 = Val(Mid(y5, InStr(y5, "x3") + 2, InStr(y5, "x4")))
f5 = Val(Mid(y5, InStr(y5, "x4") + 2, InStr(y5, "x5")))
d1 = TextBox6.Text
d2 = TextBox7.Text
d3 = TextBox8.Text
d4 = TextBox9.Text
d5 = TextBox10.Text
s = a1 * (b2 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) + b4 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b5 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4)) - a2 * (b1 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) - b5 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4)) + a3 * (b1 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) - b2 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4)) - a4 * (b1 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b2 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) + b3 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3)) + a5 * (b1 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4) - b2 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4) + b3 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4) - b4 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3))
Label7.Caption = Format(s, "####.00")
s1 = d1 * (b2 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) + b4 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b5 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4)) - a2 * (d2 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) + b4 * det(d3, c3, c5, d4, e3, e5, d5, f3, f5) - b5 * det(d3, c3, c4, d4, e3, e4, d5, f3, f4)) + a3 * (d2 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) - b2 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) + b4 * det(d3, c2, c5, d4, e2, e5, d5, f2, f5) - b5 * det(d3, c2, c4, d4, e2, e4, d5, f2, f4)) - a4 * (d2 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b2 * det(d3, c3, c5, d4, e3, e5, d5, f3, f5) + b3 * det(d3, c2, c5, d4, e2, e5, d5, f2, f5) - b5 * det(d3, c2, c3, d4, e2, e3, d5, f2, f3)) + a5 * (d2 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4) - b2 * det(d3, c3, c4, d4, e3, e4, d5, f3, f4) + b3 * det(d3, c2, c4, d4, e2, e4, d5, f2, f4) - b4 * det(d3, c2, c3, d4, e2, e3, d5, f2, f3))
s2 = a1 * (d2 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) + b4 * det(d3, c3, c5, d4, e3, e5, d5, f3, f5) - b5 * det(d3, c3, c4, d4, e3, e4, d5, f3, f4)) - d1 * (b1 * det(c3, c4, c5, e3, e4, e5, f3, f4, f5) - b3 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) - b5 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4)) + a3 * (b1 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) - d2 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) - b5 * det(c1, d3, c4, e1, d4, e4, f1, d5, f4)) - a4 * (b1 * det(d3, c3, c5, d4, e3, e5, d5, f3, f5) - d2 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) + b3 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) - b5 * det(c1, d3, c3, e1, d4, e3, f1, d5, f3)) + a5 * (b1 * det(d3, c3, c4, d4, e3, e4, d5, f3, f4) - d2 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4) + b3 * det(c1, d3, c4, e1, d4, e4, f1, d5, f4) - b4 * det(c1, d3, c3, e1, d4, e3, f1, d5, f3))
s3 = a1 * (b2 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) - d2 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) + b4 * det(c2, d3, c5, e2, d4, e5, f2, d5, f5) - b5 * det(c2, d3, c4, e2, d4, e4, f2, d5, f4)) - a2 * (b1 * det(d3, c4, c5, d4, e4, e5, d5, f4, f5) - d2 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) - b5 * det(c1, d3, c4, e1, d4, e4, f1, d5, f4)) + d1 * (b1 * det(c2, c4, c5, e2, e4, e5, f2, f4, f5) - b2 * det(c1, c4, c5, e1, e4, e5, f1, f4, f5) + b4 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4)) - a4 * (b1 * det(c2, d3, c5, e2, d4, e5, f2, d5, f5) - b2 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) + d2 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5)) + a5 * (b1 * det(c2, d3, c4, e2, d4, e4, f2, d5, f4) - b2 * det(c1, d3, c4, e1, d4, e4, f1, d5, f4) + d2 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4) - b4 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5))
s4 = a1 * (b2 * det(c3, d3, c5, e3, d4, e5, f3, d5, f5) - b3 * det(c2, d3, c5, e2, d4, e5, f2, d5, f5) + d2 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b5 * det(c2, c3, d3, e2, e3, d4, f2, f3, d5)) - a2 * (b1 * det(c3, d3, c5, e3, d4, e5, f3, d5, f5) - b3 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) + d2 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) - b5 * det(c1, c3, d3, e1, e3, d4, f1, f3, d5)) + a3 * (b1 * det(c2, d3, c5, e2, d4, e5, f2, d5, f5) - b2 * det(c1, d3, c5, e1, d4, e5, f1, d5, f5) + d2 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5)) - d1 * (b1 * det(c2, c3, c5, e2, e3, e5, f2, f3, f5) - b2 * det(c1, c3, c5, e1, e3, e5, f1, f3, f5) + b3 * det(c1, c2, c5, e1, e2, e5, f1, f2, f5) - b5 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3)) + a5 * (b1 * det(c2, c3, d3, e2, e3, d4, f2, f3, d5) - b2 * det(c1, c3, d3, e1, e3, d4, f1, f3, d5) + b3 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5) - d2 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3))
s5 = a1 * (b2 * det(c3, c4, d3, e3, e4, d4, f3, f4, d5) - b3 * det(c2, c4, d3, e2, e4, d4, f2, f4, d5) + b4 * det(c2, c3, d3, e2, e3, d4, f2, f3, d5) - d2 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4)) - a2 * (b1 * det(c3, c4, d3, e3, d4, e5, f3, f4, d5) - b3 * det(c1, c4, d3, e1, e4, d4, f1, f4, d5) + b4 * det(c1, c3, d3, e1, e3, d4, f1, f3, d5) - d2 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4)) + a3 * (b1 * det(c2, c4, d3, e2, d4, e5, f2, f4, d5) - b2 * det(c1, c4, d3, e1, e4, d4, f1, f4, d5) + b4 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5) - d2 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4)) - a4 * (b1 * det(c2, c3, d3, e2, e3, d4, f2, f3, d5) - b2 * det(c1, c3, d3, e1, e3, d4, f1, f3, d5) + b3 * det(c1, c2, d3, e1, e2, d4, f1, f2, d5) - d2 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3)) + d1 * (b1 * det(c2, c3, c4, e2, e3, e4, f2, f3, f4) - b2 * det(c1, c3, c4, e1, e3, e4, f1, f3, f4) + b3 * det(c1, c2, c4, e1, e2, e4, f1, f2, f4) - b4 * det(c1, c2, c3, e1, e2, e3, f1, f2, f3))
Label8.Caption = "x1=" & Format(s1 / s, "####.00")
Label9.Caption = "x2=" & Format(s2 / s, "####.00")
Label10.Caption = "x3=" & Format(s3 / s, "####.00")
Label11.Caption = "x4=" & Format(s4 / s, "####.00")
Label12.Caption = "x5=" & Format(s5 / s, "####.00")
End If
End Sub |