Private Sub Form_Click()
Dim a, b, c, x As Integer
a = Val(InputBox("输入A"))
b = Val(InputBox("输入B"))
c = Val(InputBox("输入C"))
x = Val(InputBox("输入X"))
Print "a * x ^ 2 + b * x=";a * x ^ 2 + b * x
End Sub
Private Sub Command1_Click()
Dim a, b, c, x As Integer
a = Val(InputBox("ÊäÈëA"))
b = Val(InputBox("ÊäÈëB"))
c = Val(InputBox("ÊäÈëC"))
If b * b - 4 * a * c < 0 Then
MsgBox "no "
Else
Print "X1 =" & (Sqr(b * b - 4 * a * c) - b) / (2 * a)
Print "X2 =" & (-Sqr(b * b - 4 * a * c) - b) / (2 * a)
End If
End Sub
Dim a%, b%, c%, s!, x1!, x2!
Private Sub Command1_Click()
a = Text1.Text
b = Text2.Text
c = Text3.Text
s = b ^ 2 - 4 * a * c
If s < 0 Then
MsgBox "无解!"
ElseIf s = 0 Then
x1 = (-b + Sqr(x)) / (2 * a)
Label1.Caption = "x" + "=" + Str(x1)
Else
x1 = (-b + Sqr(s)) / (2 * a)
x2 = (-b - Sqr(s)) / (2 * a)
Label1.Caption = "x1" + "=" + Str(x1) + vbCrLf + "x2" + "=" + Str(x2)
End If
End Sub