計算一元二次方程的兩個根的程序,分析錯誤並修改。設計界面如下圖所示,紅色的字為對象名稱。
下圖為調試、排除所有錯誤後,運行後的界面。
所提供的程序,請進行調試。
Private Sub Command1_Click()
Dim a As Integer, b As Intger
Dim c As Integer, d As Integer
Dim x1 As Single,x2 As Single
a = text1.txt
b = text2.text
c = text4.text
d = Sqr(b*b-4*a*c)
x1 = -b+d/(2*a)
x2 = -b-d/(2*a)
Label4.Caption = a & "x^2+" & b & "x+" & c & "=0"
Label.Caption = x1
Label9.Caption = x2
End Sub