编程计算一元二次方程的解 vbPrivate Sub Command1_Click() '此程序在点击按钮Command1中完成*** a As ***,b As ***,c As *** '定义变量a、b、c为长整型数*** d As Single '定义变量d为单精度实型数*** x1 As Single,x2 As Single '定义变量x1和x2为单精度实型数a = InputBox("a=") '将用户输入a的值赋值给变量ab = InputBox("b=") '将用户输入b的值赋值给变量bc = InputBox("c=") '将用户输入c的值赋值给变量cd = *** '求b^2-4ac的值赋值给变量d'以下语句判断d的值,若小于0则直接输出“此方程无解”'否则,求两个解x1和x2,并输出结果If *** ThenText***.Text = "此方程无解" '在对应的文本框中输出提示ElseX1 = (-b + Sqr(d)) / (2 * a) '计算x1的值X2 = (-b

问题描述:

编程计算一元二次方程的解 vb
Private Sub Command1_Click() '此程序在点击按钮Command1中完成
*** a As ***,b As ***,c As *** '定义变量a、b、c为长整型数
*** d As Single '定义变量d为单精度实型数
*** x1 As Single,x2 As Single '定义变量x1和x2为单精度实型数
a = InputBox("a=") '将用户输入a的值赋值给变量a
b = InputBox("b=") '将用户输入b的值赋值给变量b
c = InputBox("c=") '将用户输入c的值赋值给变量c
d = *** '求b^2-4ac的值赋值给变量d
'以下语句判断d的值,若小于0则直接输出“此方程无解”
'否则,求两个解x1和x2,并输出结果
If *** Then
Text***.Text = "此方程无解" '在对应的文本框中输出提示
Else
X1 = (-b + Sqr(d)) / (2 * a) '计算x1的值
X2 = (-b - Sqr(d)) / (2 * a) '计算x2的值
Text***.Text = "此方程的解为:" & "x1=" & x1 & "," & "x2=" & x2 '输出x1和x2的值
*** '条件语句结束
End Sub
求大侠改下 跪谢