📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8160
ClientLeft = 60
ClientTop = 450
ClientWidth = 13185
LinkTopic = "Form1"
ScaleHeight = 8160
ScaleWidth = 13185
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Caption = "请输入"
Height = 3615
Left = 240
TabIndex = 2
Top = 840
Width = 12375
Begin VB.CommandButton Command1
Caption = "计算"
Height = 495
Left = 11640
TabIndex = 13
Top = 3000
Width = 615
End
Begin VB.TextBox Text4
Height = 375
Index = 0
Left = 1440
TabIndex = 10
Top = 3000
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Left = 7920
TabIndex = 8
Top = 120
Width = 1095
End
Begin VB.TextBox Text3
Height = 495
Index = 0
Left = 2160
TabIndex = 6
Top = 840
Width = 1095
End
Begin VB.TextBox Text1
Height = 495
Left = 2160
TabIndex = 4
Top = 240
Width = 1095
End
Begin VB.Label Label3
Caption = "请输入权阵P:"
Height = 375
Left = 240
TabIndex = 9
Top = 3120
Width = 1335
End
Begin VB.Label Label5
Caption = "请输入观测值个数n:"
Height = 495
Left = 6000
TabIndex = 7
Top = 240
Width = 1815
End
Begin VB.Label Label2
Caption = "请输入条件式系数矩阵A:"
Height = 375
Left = 120
TabIndex = 5
Top = 960
Width = 2175
End
Begin VB.Label Label6
Caption = "请输入条件式个数r:"
Height = 375
Left = 240
TabIndex = 3
Top = 360
Width = 1815
End
End
Begin VB.Frame Frame1
Caption = "法方程系数"
Height = 2295
Left = 240
TabIndex = 1
Top = 4800
Width = 12495
Begin VB.TextBox Text5
Height = 495
Index = 0
Left = 1800
TabIndex = 12
Top = 240
Width = 1215
End
Begin VB.Label Label4
Caption = "法方程系数如下:"
Height = 615
Left = 120
TabIndex = 11
Top = 360
Width = 1575
End
End
Begin VB.Line Line1
X1 = 240
X2 = 12720
Y1 = 4680
Y2 = 4680
End
Begin VB.Label Label1
Caption = "条件平差的法方程系数组成"
BeginProperty Font
Name = "华文行楷"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 3000
TabIndex = 0
Top = 120
Width = 6855
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(), B(), P()
Dim r, n, i, j, k, 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 B(1 To r, 1 To r)
ReDim P(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
'给A数组的每一个元素赋值并与A矩阵相对应
For k = 0 To total - 1
i = Int(k / n) + 1
j = (k + n) Mod n + 1
A(i, j) = Val(Text3(k).Text)
Next k
'给P数组的每一个元素赋值并与P矩阵相对应
For i = 1 To n
P(i) = Val(Me.Text4(i - 1).Text)
Next i
'加载法方程的各个系数文本框
For i = 1 To fa - 1
Load Text5(i)
With Text5(i)
If i Mod r = 0 Then
.Top = Text5(i - 1).Top + .Height
.Left = Text5(i - r).Left
.Visible = True
Else
.Top = Text5(i - 1).Top
.Left = Text5(i - 1).Left + .Width
.Visible = True
End If
End With
Next i
'计算系数矩阵B(i,j)
For i = 1 To r
For j = 1 To r
For k = 1 To n
B(i, j) = B(i, j) + A(i, k) * A(j, k) / P(k)
Next k
Next j
Next i
'将系数矩阵B(i,j)显示在界面的文本框5上
For k = 0 To fa - 1
i = Int(k / r) + 1
j = (k + r) Mod r + 1
Me.Text5(k).Text = Str(B(i, j))
Next k
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
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
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 + -