📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 9090
ClientLeft = 60
ClientTop = 450
ClientWidth = 13920
LinkTopic = "Form1"
ScaleHeight = 9090
ScaleWidth = 13920
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame3
Caption = "Frame3"
Height = 1455
Left = 120
TabIndex = 14
Top = 7440
Width = 12855
Begin VB.TextBox Text6
Height = 495
Index = 0
Left = 1320
TabIndex = 16
Top = 360
Width = 855
End
Begin VB.Label Label8
Caption = "最或然误差v:"
Height = 495
Left = 120
TabIndex = 15
Top = 480
Width = 1335
End
End
Begin VB.Frame Frame2
Caption = "Frame2"
Height = 5535
Left = 120
TabIndex = 7
Top = 1800
Width = 12855
Begin VB.CommandButton Command1
Caption = "计算"
Height = 495
Left = 11760
TabIndex = 17
Top = 4920
Width = 975
End
Begin VB.TextBox Text5
Height = 495
Index = 0
Left = 960
TabIndex = 13
Top = 4920
Width = 855
End
Begin VB.TextBox Text4
Height = 495
Index = 0
Left = 960
TabIndex = 11
Top = 3960
Width = 855
End
Begin VB.TextBox Text3
Height = 495
Index = 0
Left = 1320
TabIndex = 9
Top = 240
Width = 735
End
Begin VB.Label Label7
Caption = "联系数K:"
Height = 375
Left = 120
TabIndex = 12
Top = 5040
Width = 855
End
Begin VB.Label Label6
Caption = "权阵P:"
Height = 375
Left = 120
TabIndex = 10
Top = 4200
Width = 975
End
Begin VB.Label Label5
Caption = "条件系数阵A:"
Height = 495
Left = 120
TabIndex = 8
Top = 360
Width = 1215
End
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 1095
Left = 120
TabIndex = 1
Top = 600
Width = 12855
Begin VB.TextBox Text2
Height = 495
Left = 2520
TabIndex = 5
Top = 480
Width = 855
End
Begin VB.TextBox Text1
Height = 495
Left = 840
TabIndex = 3
Top = 480
Width = 855
End
Begin VB.Label Label4
Caption = "请先输入:"
Height = 255
Left = 120
TabIndex = 6
Top = 240
Width = 975
End
Begin VB.Label Label3
Caption = "n值:"
Height = 375
Left = 1920
TabIndex = 4
Top = 480
Width = 1335
End
Begin VB.Label Label2
Caption = "r值:"
Height = 375
Left = 120
TabIndex = 2
Top = 600
Width = 1575
End
End
Begin VB.Label Label1
Caption = "求最或然误差V"
BeginProperty Font
Name = "华文行楷"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 3840
TabIndex = 0
Top = 120
Width = 3735
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 A(), k(), P(), v()
Dim r, n, i, j, h
r = Val(Text1.Text)
n = Val(Text2.Text)
'法方程系数的个数fa
fa = r * r
total = r * n
ReDim A(1 To r, 1 To n)
ReDim k(1 To r)
ReDim P(1 To n)
ReDim v(1 To n)
'填写A矩阵的每一个系数
For i = 0 To total - 1
If Me.Text3(i).Text = "" Then
cc = MsgBox("请输入完整的A矩阵系数!", , "输入A系数!")
Text3(i).SetFocus
End If
Next i
'填写P矩阵的每一个系数
For i = 0 To n - 1
If Me.Text4(i).Text = "" Then
cc = MsgBox("请输入完整的P矩阵系数!", , "输入P系数!")
Text4(i).SetFocus
End If
Next i
'填写K矩阵的每一个系数
For i = 0 To r - 1
If Me.Text5(i).Text = "" Then
cc = MsgBox("请输入完整的K矩阵系数!", , "输入K系数!")
Text5(i).SetFocus
End If
Next i
'给A数组的每一个元素赋值并与A矩阵相对应
For h = 0 To total - 1
i = Int(h / n) + 1
j = (h + n) Mod n + 1
A(i, j) = Val(Text3(h).Text)
Next h
'给P数组的每一个元素赋值并与P矩阵相对应
For i = 1 To n
P(i) = Val(Me.Text4(i - 1).Text)
Next i
'给K数组的每一个元素赋值并与P矩阵相对应
For i = 1 To r
v(i) = Val(Me.Text5(i - 1).Text)
Next i
'在界面上加载最或然误差v的文本框
For i = 1 To n - 1
Load Text6(i)
With Text6(i)
.Left = Text6(i - 1).Left + .Width
.Visible = True
End With
Next i
'计算最或然误差v
For i = 1 To n
For j = 1 To r
v(i) = v(i) + A(j, i) * k(j) / P(i)
Next j
Next i
'在界面上文本框内显示v值
For h = 1 To n
Me.Text6(h - 1).Text = Str(v(h))
Next h
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim r, j, k, n, total As Integer
'加载A系数矩阵文本框
If KeyAscii = 13 And Me.Text2.Text <> "" Then
r = Val(Text1.Text)
n = Val(Text2.Text)
total = r * n
For i = 1 To total - 1
Load Text3(i)
With Text3(i)
If i Mod n = 0 Then
.Top = Text3(i - 1).Top + .Height
.Left = Text3(i - n).Left
.Visible = True
Else
.Top = Text3(i - 1).Top
.Left = Text3(i - 1).Left + .Width
.Visible = True
End If
End With
Next i
'加载P系数矩阵
For i = 1 To n - 1
Load Text4(i)
With Text4(i)
' .Top = Text2(i - 1).Top
.Left = Text4(i - 1).Left + .Width
.Visible = True
End With
Next i
'加载联系数K矩阵
For i = 1 To r - 1
Load Text5(i)
With Text5(i)
.Left = Text5(i - 1).Left + .Width
.Visible = True
End With
Next i
ElseIf KeyAscii = 13 And Me.Text2.Text = "" Then
'MsgBox "请输入观测值个数n!", "输入n值!"
bb = MsgBox("请输入观测值个数n!", , "输入n值")
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim r, j, k, n, total As Integer
'加载A矩阵系数文本框
If KeyAscii = 13 And Me.Text1.Text <> "" Then
r = Val(Text1.Text)
n = Val(Text2.Text)
total = r * n
For i = 1 To total - 1
Load Text3(i)
With Text3(i)
If i Mod n = 0 Then
.Top = Text3(i - 1).Top + .Height
.Left = Text3(i - n).Left
.Visible = True
Else
.Top = Text3(i - 1).Top
.Left = Text3(i - 1).Left + .Width
.Visible = True
End If
End With
Next i
'加载P系数矩阵
For i = 1 To n - 1
Load Text4(i)
With Text4(i)
' .Top = Text2(i - 1).Top
.Left = Text4(i - 1).Left + .Width
.Visible = True
End With
Next i
'加载联系数K矩阵
For i = 1 To r - 1
Load Text5(i)
With Text5(i)
.Left = Text5(i - 1).Left + .Width
.Visible = True
End With
Next i
ElseIf KeyAscii = 13 And Me.Text1.Text = "" Then
'MsgBox "请输入观测值个数n!", "输入n值!"
aa = MsgBox("请输入条件式个数r!", , "输入r值")
Text1.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -