📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "方程求解"
ClientHeight = 5145
ClientLeft = 4785
ClientTop = 3375
ClientWidth = 5640
LinkTopic = "Form1"
ScaleHeight = 5145
ScaleWidth = 5640
Begin VB.CommandButton Command2
Caption = "退 出"
Height = 495
Left = 2760
TabIndex = 14
Top = 4560
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "求 解"
Height = 495
Left = 1200
TabIndex = 13
Top = 4560
Width = 1215
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3600
TabIndex = 6
Top = 1320
Width = 735
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2040
TabIndex = 4
Top = 1320
Width = 735
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 1
Top = 1320
Width = 735
End
Begin VB.Label Label10
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 12
Top = 3240
Width = 255
End
Begin VB.Label Label9
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 11
Top = 4080
Width = 255
End
Begin VB.Label Label8
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 10
Top = 3720
Width = 4815
End
Begin VB.Label Label7
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 9
Top = 2880
Width = 4815
End
Begin VB.Label Label6
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 8
Top = 2160
Width = 4815
End
Begin VB.Label Label5
Caption = "= 0"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4320
TabIndex = 7
Top = 1320
Width = 855
End
Begin VB.Label Label4
Caption = "X +"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2760
TabIndex = 5
Top = 1320
Width = 855
End
Begin VB.Label Label3
Caption = "2"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1440
TabIndex = 3
Top = 1200
Width = 255
End
Begin VB.Label Label2
Caption = "X +"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1200
TabIndex = 2
Top = 1320
Width = 855
End
Begin VB.Label Label1
Caption = "请输入方程的系数"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1320
TabIndex = 0
Top = 360
Width = 3135
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 As Double
Dim b As Double
Dim c As Double
Dim k As Double
Dim s As Double
Dim m As Double
Dim s1 As Double
Dim s2 As Double
Dim ss1 As Double
Dim ss2 As Double
Dim ss As Double
Label6.Caption = ""
Label7.Caption = ""
Label8.Caption = ""
Label9.Caption = ""
Label10.Caption = ""
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
k = b * b - 4 * a * c
If k < 0 Then
m = (-k) ^ (1 / 2)
ss = -b / (2 * a)
ss1 = m / (2 * a)
ss2 = (-m) / (2 * a)
Label6.Caption = "方程有两个不同的虚根:"
If ss1 > 0 Then
Label7.Caption = "X =" & Format(ss, "0.0000") & "+" & Format(ss1, "0.0000") & "i"
Label8.Caption = "X =" & Format(ss, "0.0000") & Format(ss2, "0.0000") & "i"
Else
Label7.Caption = "X =" & Format(ss, "0.0000") & Format(ss1, "0.0000") & "i"
Label8.Caption = "X =" & Format(ss, "0.0000") & "+" & Format(ss2, "0.0000") & "i"
End If
Label9.Caption = "2"
Label10.Caption = "1"
ElseIf k = 0 Then
s = -b / 2 * a
Label6.Caption = "方程有两个相同的解:"
Label7.Caption = "X =" & Format(s, "0.00000")
Else
m = k ^ (1 / 2)
s1 = (-b + m) / 2 * a
s2 = (-b - m) / 2 * a
Label6.Caption = "方程有两个不同的解:"
Label7.Caption = "X =" & Format(s1, "0.00000")
Label8.Caption = "X =" & Format(s2, "0.00000")
Label9.Caption = "2"
Label10.Caption = "1"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -