📄 线性方程.frm
字号:
If SSTab1.Tab = 0 Then '已知两点
xa = Val(Text1.Text)
ya = Val(Text2.Text)
xb = Val(Text3.Text)
yb = Val(Text4.Text)
List1.Clear
List1.AddItem " ----原始数据----"
List1.AddItem " " + Label1.Caption + Text1.Text
List1.AddItem " " + Label2.Caption + Text2.Text
List1.AddItem " " + Label3.Caption + Text3.Text
List1.AddItem " " + Label4.Caption + Text4.Text
List1.AddItem ""
List1.AddItem " ~~~~线性方程~~~~"
If xb - xa <> 0 And yb - ya <> 0 Then
aa = (yb - ya) / (xb - xa)
bb = yb - aa * xb
List1.AddItem " " + "Y=" + Trim(Str(aa)) + "X" + "+" + Trim(Str(bb))
End If
If xb - xa = 0 And yb - ya <> 0 Then
aa = xa
bb = 0
List1.AddItem " " + "X=" + Trim(Str(aa))
End If
If xb - xa <> 0 And yb - ya = 0 Then
aa = 0
bb = ya
List1.AddItem " " + "Y=" + Trim(Str(bb))
End If
If xb - xa = 0 And yb - ya = 0 Then
aa = 0
bb = 0
List1.AddItem " " + "为个一点"
End If
End If
If SSTab1.Tab = 1 Then '已知一点和K
xa = Val(Text5.Text)
ya = Val(Text6.Text)
k = Val(Text7.Text)
aa = k
bb = ya - aa * xa
List1.Clear
List1.AddItem " ----原始数据----"
List1.AddItem " " + Label5.Caption + Text5.Text
List1.AddItem " " + Label6.Caption + Text6.Text
List1.AddItem " " + Label7.Caption + Text7.Text
List1.AddItem ""
List1.AddItem " ~~~~线性方程~~~~"
List1.AddItem " " + "Y=" + Trim(Str(aa)) + "X" + "+" + Trim(Str(bb))
End If
Exit Sub
handlerror:
xiansh = MsgBox("在计算时出错,请检查数据后再试试。", vbInformation, "信息提示")
End Sub
Private Sub Command2_Click()
'关闭
On Error GoTo handlerror
If List1.ListCount > 1 And rjsfzc = 88 Then
frmMain.Text1 = frmMain.Text1 & vbCrLf & ""
frmMain.Text1 = frmMain.Text1 & vbCrLf & " 《线性方程计算结果》"
frmMain.Text1 = frmMain.Text1 & vbCrLf & ""
For i = 0 To List1.ListCount - 1
frmMain.Text1 = frmMain.Text1 & vbCrLf & List1.List(i)
Next i
frmMain.Text1 = frmMain.Text1 & vbCrLf & " --------------------------------------"
End If
Unload Me
Exit Sub
handlerror:
End Sub
Private Sub Command3_Click()
'插值>>>
On Error GoTo handlerror
xx = Val(Text8.Text)
yy = aa * xx + bb
Text9.Text = Trim(Str(yy))
List1.AddItem ""
List1.AddItem " X=" + Trim(Text8.Text) + " Y=" + Trim(Text9.Text)
Exit Sub
handlerror:
End Sub
Private Sub Command4_Click()
'插值<<<
On Error GoTo handlerror
yy = Val(Text9.Text)
xx = (yy - bb) / aa
Text8.Text = Trim(Str(xx))
List1.AddItem ""
List1.AddItem " X=" + Trim(Text8.Text) + " Y=" + Trim(Text9.Text)
Exit Sub
handlerror:
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
'Esc键退出,VbEscape可以用27代替
On Error GoTo handlerror
If KeyAscii = 27 Then
Unload Me
End If
Exit Sub
handlerror:
End Sub
Private Sub Form_Load()
'启动
On Error GoTo handlerror
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
List1.Clear
Exit Sub
handlerror:
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
'点击页面
On Error GoTo handlerror
If SSTab1.Tab = 0 Then Text1.SetFocus
If SSTab1.Tab = 1 Then Text5.SetFocus
If SSTab1.Tab = 2 Then Text8.SetFocus
Exit Sub
handlerror:
End Sub
Private Sub Text1_Click()
'点击
On Error GoTo handlerror
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text2_Click()
'点击
On Error GoTo handlerror
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text3_Click()
'点击
On Error GoTo handlerror
Text3.SelStart = 0
Text3.SelLength = Len(Text3.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text4_Click()
'点击
On Error GoTo handlerror
Text4.SelStart = 0
Text4.SelLength = Len(Text4.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text5_Click()
'点击
On Error GoTo handlerror
Text5.SelStart = 0
Text5.SelLength = Len(Text5.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text6_Click()
'点击
On Error GoTo handlerror
Text6.SelStart = 0
Text6.SelLength = Len(Text6.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text7_Click()
'点击
On Error GoTo handlerror
Text7.SelStart = 0
Text7.SelLength = Len(Text7.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text8_Click()
'点击
On Error GoTo handlerror
Text8.SelStart = 0
Text8.SelLength = Len(Text8.Text)
Exit Sub
handlerror:
End Sub
Private Sub Text9_Click()
'点击
On Error GoTo handlerror
Text9.SelStart = 0
Text9.SelLength = Len(Text9.Text)
Exit Sub
handlerror:
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -