📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8505
ClientLeft = 60
ClientTop = 450
ClientWidth = 13290
LinkTopic = "Form1"
ScaleHeight = 8505
ScaleWidth = 13290
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text4
Height = 615
Left = 11760
TabIndex = 10
Top = 240
Width = 975
End
Begin VB.Frame Frame2
Caption = "Frame2"
Height = 2775
Left = 360
TabIndex = 6
Top = 5280
Width = 12015
Begin VB.TextBox Text3
Height = 615
Index = 0
Left = 1440
TabIndex = 8
Top = 240
Width = 1335
End
Begin VB.Label Label4
Caption = "联系数k"
Height = 615
Left = 240
TabIndex = 7
Top = 480
Width = 1335
End
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 4335
Left = 240
TabIndex = 1
Top = 840
Width = 12015
Begin VB.CommandButton Command1
Caption = "计算"
Height = 495
Left = 11040
TabIndex = 9
Top = 3720
Width = 855
End
Begin VB.TextBox Text1
Height = 495
Index = 0
Left = 1320
TabIndex = 5
Top = 360
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Index = 0
Left = 1440
TabIndex = 3
Top = 3840
Width = 1335
End
Begin VB.Label Label2
Caption = "逆矩阵q"
Height = 615
Left = 360
TabIndex = 4
Top = 480
Width = 1215
End
Begin VB.Label Label3
Caption = "闭合差w"
Height = 615
Left = 240
TabIndex = 2
Top = 3720
Width = 975
End
End
Begin VB.Label Label5
Caption = "请先输入维数:"
Height = 255
Left = 10080
TabIndex = 11
Top = 480
Width = 1335
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "求联系数k"
BeginProperty Font
Name = "华文行楷"
Size = 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 2280
TabIndex = 0
Top = 240
Width = 7095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim q(), w(), k()
Dim r, n, i, j, h
r = Val(Me.Text4.Text)
n = Val(Text4.Text) * Val(Text4.Text)
ReDim q(1 To r, 1 To r)
ReDim w(1 To r)
ReDim k(1 To r)
'填写矩阵q 的每一个系数
For i = 0 To n - 1
If Me.Text1(i).Text = "" Then
MsgBox "请输入完整的q矩阵!", "输入q矩阵!"
Text1(i).SetFocus
End If
Next i
'给数组q的每一个元素赋值
For h = 0 To n - 1
i = Int(h / r) + 1
j = (h + r) Mod r + 1
q(i, j) = Val(Text1(h).Text)
Next h
'填写矩阵w 的每一个系数
For i = 0 To r - 1
If Me.Text2(i).Text = "" Then
MsgBox "请输入完整的w矩阵!", "输入w矩阵!"
Text2(i).SetFocus
End If
Next i
'给数组w的每一个元素赋值
For h = 1 To r
w(h) = Val(Text2(h - 1).Text)
Next h
'计算联系数k
For i = 1 To r
For j = 1 To r
k(i) = k(i) - q(i, j) * w(j)
Next j
Next i
'在窗体上加载联系数k的文本框
For i = 1 To r - 1
Load Text3(i)
With Text3(i)
' .Top = Text2(i - 1).Top
.Left = Text3(i - 1).Left + .Width
.Visible = True
End With
Next i
'在文本框3当中打印联系数k
For h = 1 To r
Me.Text3(h - 1).Text = Str(k(h))
Next h
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
Dim i, j, k, n As Integer
If KeyAscii = 13 Then
n = Val(Text4.Text)
total = n * n
For i = 1 To n - 1
Load Text2(i)
With Text2(i)
' .Top = Text2(i - 1).Top
.Left = Text2(i - 1).Left + .Width
.Visible = True
End With
Next i
For j = 1 To total - 1
Load Text1(j)
With Text1(j)
If j Mod n = 0 Then
.Top = Text1(j - 1).Top + .Height
.Left = Text1(j - n).Left
.Visible = True
Else
.Top = Text1(j - 1).Top
.Left = Text1(j - 1).Left + .Width
.Visible = True
End If
End With
Next j
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -