📄 form1.frm
字号:
Index = 2
Left = 1080
TabIndex = 6
Text = "1"
Top = 1320
Width = 735
End
Begin VB.TextBox Text2
Height = 375
Index = 1
Left = 120
TabIndex = 5
Text = "1"
Top = 1320
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Index = 6
Left = 5040
TabIndex = 4
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Index = 5
Left = 3960
TabIndex = 3
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Index = 4
Left = 3000
TabIndex = 2
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 2040
TabIndex = 1
Text = "4"
Top = 600
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 1080
TabIndex = 0
Text = "3"
Top = 600
Width = 735
End
Begin VB.Label Label1
Caption = "阶"
Height = 375
Left = 1800
TabIndex = 30
Top = 5160
Width = 375
End
Begin VB.Line Line2
X1 = 120
X2 = 5880
Y1 = 4080
Y2 = 4080
End
Begin VB.Line Line1
X1 = 5880
X2 = 5880
Y1 = 240
Y2 = 4920
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim n As Integer
Dim i As Integer
Dim j As Integer
Dim t As Integer
Dim b(6) As Double
Dim a(6, 6) As Double
Private Sub Command1_Click()
n = CInt(Text8.Text)
For i = 1 To n
a(1, i) = Text1(i).Text
Next i
For i = 1 To n
b(i) = CDbl(Text7(i).Text)
Next i
If n < 6 Then
For i = n + 1 To 6
Text1(i).Visible = False
Text2(i).Visible = False
Text3(i).Visible = False
Text4(i).Visible = False
Text5(i).Visible = False
Text6(i).Visible = False
Text7(i).Visible = False
Next i
End If
If n = 1 Then
Text2(1).Visible = False
Text3(1).Visible = False
Text4(1).Visible = False
Text5(1).Visible = False
Text6(1).Visible = False
For i = 2 To 6
Text7(i).Visible = False
Next i
End If
If n = 2 Then
For i = 1 To n
Text3(i).Visible = False
Text4(i).Visible = False
Text5(i).Visible = False
Text6(i).Visible = False
For j = 3 To 6
Text7(j).Visible = False
Next j
Next i
End If
If n = 3 Then
For i = 1 To n
Text4(i).Visible = False
Text5(i).Visible = False
Text6(i).Visible = False
For j = 4 To 6
Text7(j).Visible = False
Next j
Next i
End If
If n = 4 Then
For i = 1 To n
Text5(i).Visible = False
Text6(i).Visible = False
For j = 5 To 6
Text7(j).Visible = False
Next j
Next i
End If
If n = 5 Then
For i = 1 To n
Text6(i).Visible = False
Next i
Text7(6).Visible = False
End If
If n = 6 Then
For i = 1 To 6
a(1, i) = CDbl(Text1(i).Text)
a(2, i) = CDbl(Text2(i).Text)
a(3, i) = CDbl(Text3(i).Text)
a(4, i) = CDbl(Text4(i).Text)
a(5, i) = CDbl(Text5(i).Text)
a(6, i) = CDbl(Text6(i).Text)
Next i
End If
If n = 5 Then
For i = 1 To 5
a(1, i) = CDbl(Text1(i).Text)
a(2, i) = CDbl(Text2(i).Text)
a(3, i) = CDbl(Text3(i).Text)
a(4, i) = CDbl(Text4(i).Text)
a(5, i) = CDbl(Text5(i).Text)
Next i
End If
If n = 4 Then
For i = 1 To 4
a(1, i) = CDbl(Text1(i).Text)
a(2, i) = CDbl(Text2(i).Text)
a(3, i) = CDbl(Text3(i).Text)
a(4, i) = CDbl(Text4(i).Text)
Next i
End If
If n = 3 Then
For i = 1 To 3
a(1, i) = CDbl(Text1(i).Text)
a(2, i) = CDbl(Text2(i).Text)
a(3, i) = CDbl(Text3(i).Text)
Next i
End If
If n = 2 Then
For i = 1 To 2
a(1, i) = CDbl(Text1(i).Text)
a(2, i) = CDbl(Text2(i).Text)
Next i
End If
If n = 1 Then MsgBox "是你有问题还是我有问题?!这个也要麻烦计算机啊!!靠!"
For t = 1 To n - 1
For i = t + 1 To n
For j = t + 1 To n
a(i, j) = a(i, j) - a(i, t) / a(t, t) * a(t, j)
Next j
b(i) = b(i) - a(i, t) / a(t, t) * b(t)
For j = 1 To t
a(i, j) = 0
Next j
Next i
Call valuetext
Next t
For t = n To 2 Step -1
For i = t - 1 To 1 Step -1
b(i) = b(i) - b(t) * a(i, t) / a(t, t)
a(i, t) = 0
Next i
Next t
For i = 1 To n
b(i) = b(i) / a(i, i)
a(i, i) = 1
Next i
Call valuetext
End Sub '""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Function valuetext()
If n = 1 Then Text1(1).Text = ccstr(a(1, 1))
If n = 6 Then
For i = 1 To 6
Text1(i).Text = ccstr(a(1, i))
Text2(i).Text = ccstr(a(2, i))
Text3(i).Text = ccstr(a(3, i))
Text4(i).Text = ccstr(a(4, i))
Text5(i).Text = ccstr(a(5, i))
Text6(i).Text = ccstr(a(6, i))
Text7(i).Text = ccstr(b(i))
Next i
End If
If n = 5 Then
For i = 1 To 5
Text1(i).Text = ccstr(a(1, i))
Text2(i).Text = ccstr(a(2, i))
Text3(i).Text = ccstr(a(3, i))
Text4(i).Text = ccstr(a(4, i))
Text5(i).Text = ccstr(a(5, i))
Text7(i).Text = ccstr(b(i))
Next i
End If
If n = 4 Then
For i = 1 To 4
Text1(i).Text = ccstr(a(1, i))
Text2(i).Text = ccstr(a(2, i))
Text3(i).Text = ccstr(a(3, i))
Text4(i).Text = ccstr(a(4, i))
Text7(i).Text = ccstr(b(i))
Next i
End If
If n = 3 Then
For i = 1 To 3
Text1(i).Text = ccstr(a(1, i))
Text2(i).Text = ccstr(a(2, i))
Text3(i).Text = ccstr(a(3, i))
Text7(i).Text = ccstr(b(i))
Next i
End If
If n = 2 Then
For i = 1 To 2
Text1(i).Text = ccstr(a(1, i))
Text2(i).Text = ccstr(a(2, i))
Text7(i).Text = ccstr(b(i))
Next i
End If
End Function
Function ccstr(a As Double)
If 0 < a And a < 1 Then ccstr = "0" + CStr(a) '特殊情况 为-1到1 之间的数字
If -1 < a And a < 0 Then ccstr = "-0" + CStr(Abs(a))
If CStr(a) = "0" Then ccstr = "0"
If Abs(a) >= 1 Then ccstr = CStr(a)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -