Private Sub init_Click()
Form1.Cls *清屏
Picture1.Cls
Picture2.Cls
Text1 = ""
Text2 = ""
Label6 = ""
Dim a#, b#, c#
a = Val(InputBox("输入系数a"))
If a = 0 Then MsgBox "一元2次方程,系数a不能为0": Exit Sub
b = Val(InputBox("输入系数b"))
c = Val(InputBox("输入系数c"))
Picture1.Print ""; a; "x^2+"; b; "x+("; c; ")=0"
Open "d:\date.txt" For Output As #1
Write #1, a, b, c
Close #1
End Sub
Private Sub quit_Click()
End
End Sub
Private Sub solve_Click()
If Dir("d:\date.txt") = "" Then
MsgBox "请先系数初始化 ": Exit Sub
End If
Open "d:\date.txt" For Input As #1
Dim a#, b#, c#
Do While Not EOF(1)
Input #1, a, b, c
Loop
Close #1
delta = b ^ 2 - 4 * a * c
If delta > 0 Then
Picture2.Print "有两个不同的实根"
X1 = Val((-b + Sqr(b ^ 2 - 4 * a * c)) / (2 * a))
X2 = Val((-b - Sqr(b ^ 2 - 4 * a * c)) / (2 * a))
Text1 = Format(X1, "0.00000")
Text2 = Format(X2, "0.00000")
ElseIf delta = 0 Then
Picture2.Print "有两个相同的实根"
Text1 = -b / (2 * a)
Text2 = Text1
Else
Picture2.Print "方程无实根"
End If
End Sub
这个是代码