📄 方程交点.frm
字号:
VERSION 5.00
Begin VB.Form frmjfcjd
BorderStyle = 1 'Fixed Single
Caption = "解方程"
ClientHeight = 3690
ClientLeft = 45
ClientTop = 345
ClientWidth = 6930
Icon = "方程交点.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3690
ScaleWidth = 6930
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox List1
Height = 2940
Left = 4200
TabIndex = 25
Top = 240
Width = 2655
End
Begin VB.CommandButton Command3
Caption = "下一个"
Height = 375
Left = 4200
TabIndex = 23
Top = 3240
Width = 855
End
Begin VB.CommandButton Command2
Caption = "关闭"
Height = 375
Left = 6000
TabIndex = 22
Top = 3240
Width = 855
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 5160
TabIndex = 21
Top = 3240
Width = 855
End
Begin VB.Frame Frame3
Caption = "交点"
Height = 855
Left = 120
TabIndex = 16
Top = 2760
Width = 3975
Begin VB.TextBox Text9
Height = 270
Left = 2400
Locked = -1 'True
TabIndex = 20
Text = "Text9"
Top = 360
Width = 1335
End
Begin VB.TextBox Text8
Height = 270
Left = 480
Locked = -1 'True
TabIndex = 19
Text = "Text8"
Top = 360
Width = 1335
End
Begin VB.Label Label9
Caption = "Y="
Height = 255
Left = 2040
TabIndex = 18
Top = 360
Width = 615
End
Begin VB.Label Label8
Caption = "X="
Height = 255
Left = 120
TabIndex = 17
Top = 360
Width = 375
End
End
Begin VB.Frame Frame2
Caption = "方程2"
Height = 1215
Left = 120
TabIndex = 5
Top = 1440
Width = 3975
Begin VB.TextBox Text7
Height = 270
Left = 2640
TabIndex = 15
Text = "Text7"
ToolTipText = "1:0.75,输入0.75"
Top = 360
Width = 1095
End
Begin VB.TextBox Text6
Height = 270
Left = 480
TabIndex = 14
Text = "Text6"
Top = 840
Width = 1335
End
Begin VB.TextBox Text5
Height = 270
Left = 480
TabIndex = 13
Text = "Text5"
Top = 360
Width = 1335
End
Begin VB.Label Label10
Caption = "注意正负:/正、\负"
Height = 255
Left = 2040
TabIndex = 24
Top = 840
Width = 1695
End
Begin VB.Label Label7
Caption = "斜率K="
Height = 255
Left = 2040
TabIndex = 8
Top = 360
Width = 855
End
Begin VB.Label Label6
Caption = "Y3="
Height = 255
Left = 120
TabIndex = 7
Top = 840
Width = 855
End
Begin VB.Label Label5
Caption = "X3="
Height = 255
Left = 120
TabIndex = 6
Top = 360
Width = 855
End
End
Begin VB.Frame Frame1
Caption = "方程1"
Height = 1215
Left = 120
TabIndex = 0
Top = 120
Width = 3975
Begin VB.TextBox Text4
Height = 270
Left = 2400
TabIndex = 12
Text = "Text4"
Top = 840
Width = 1335
End
Begin VB.TextBox Text3
Height = 270
Left = 2400
TabIndex = 11
Text = "Text3"
Top = 360
Width = 1335
End
Begin VB.TextBox Text2
Height = 270
Left = 480
TabIndex = 10
Text = "Text2"
Top = 840
Width = 1335
End
Begin VB.TextBox Text1
Height = 270
Left = 480
TabIndex = 9
Text = "Text1"
Top = 360
Width = 1335
End
Begin VB.Label Label4
Caption = "Y2="
Height = 255
Left = 2040
TabIndex = 4
Top = 840
Width = 855
End
Begin VB.Label Label3
Caption = "X2="
Height = 255
Left = 2040
TabIndex = 3
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "Y1="
Height = 255
Left = 120
TabIndex = 2
Top = 840
Width = 495
End
Begin VB.Label Label1
Caption = "X1="
Height = 255
Left = 120
TabIndex = 1
Top = 360
Width = 495
End
End
End
Attribute VB_Name = "frmjfcjd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ii As Integer
Private Sub Command1_Click()
'计算
Dim x1 As Double, y1 As Double
Dim x2 As Double, y2 As Double
Dim x3 As Double, y3 As Double
Dim x As Double, y As Double
Dim k As Double
Dim aa As Double, bb As Double
On Error GoTo handlerror
x1 = Val(Text1.Text)
y1 = Val(Text2.Text)
x2 = Val(Text3.Text)
y2 = Val(Text4.Text)
x3 = Val(Text5.Text)
y3 = Val(Text6.Text)
k = Val(Text7.Text)
If k <> 0 Then k = 1 / k
x = ((y3 - k * x3) * (x2 - x1) - (x2 - x1) * y1 + x1 * (y2 - y1)) / ((y2 - y1) - k * (x2 - x1))
' x = ((y2 - y1) * x1 - k * x3 * (x2 - x1) + y3 * (x2 - x1)) / ((y2 - y1) - k * (x2 - x1))
y = k * (x - x3) + y3
aa = x
bb = y
Text8.Text = Trim(Str(Int(aa * 10000 + 0.5) / 10000))
Text9.Text = Trim(Str(Int(bb * 10000 + 0.5) / 10000))
'写入
List1.AddItem " ----交点 " + Trim(Str(ii)) + "----"
List1.AddItem ""
List1.AddItem " 方程1参数"
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 " 方程2参数"
List1.AddItem " " + Label5.Caption + Text5.Text
List1.AddItem " " + Label6.Caption + Text6.Text
List1.AddItem " " + Label7.Caption + Text7.Text
List1.AddItem ""
List1.AddItem " 交点坐标"
List1.AddItem " " + Label8.Caption + Text8.Text
List1.AddItem " " + Label9.Caption + Text9.Text
List1.AddItem ""
ii = ii + 1
Command3.SetFocus
Exit Sub
handlerror:
xiansh = MsgBox("计算出错,请检查数据后再试试。", vbInformation, "信息提示")
End Sub
Private Sub Command1_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
Command3.SetFocus
End If
Exit Sub
handlerror:
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
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text8.Text = ""
Text9.Text = ""
Text1.SetFocus
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
ii = 1
Exit Sub
handlerror:
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text2.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text3.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text4.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text5.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text6.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Text7.SelStart = 0
Text7.SelLength = Len(Text7.Text)
Text7.SetFocus
End If
Exit Sub
handlerror:
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
'回车
On Error GoTo handlerror
If KeyAscii = 13 Then
KeyAscii = 0
Command1.SetFocus
End If
Exit Sub
handlerror:
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -