📄 条件平差方程代码.txt
字号:
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 + -