说明:需下载vb6.0,打开程序后,双击编写窗口打开代码编辑框,右上角有个"Load",点旁边的选项(一个向下的箭头),选"click"
代码如下:
start = InputBox("输入0开始运算", "确认方程已化成普通形式")
If start = 0 Then
Dim a, b, c As Integer
a = InputBox("a", "输入一次项系数")
b = InputBox("b", "输入二次项系数")
c = InputBox("c", "输入常数")
If b ^ 2 - 4 * a * c >= 0 Then
x = (-b + Sqr(b ^ 2 - 4 * a * c)) / 2 * a
y = (-b - Sqr(b ^ 2 - 4 * a * c)) / 2 * a
If x = y Then
Print "x1=x2="; "-"; b; "±"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; x
Else
Print "x1="; "-"; b; "+"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; x; "x2="; "-"; b; "-"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; y
End If
Else
Print "方程无实数根"
End If
Else
End
End If
ok,有神马不懂得请留言
代码如下:
start = InputBox("输入0开始运算", "确认方程已化成普通形式")
If start = 0 Then
Dim a, b, c As Integer
a = InputBox("a", "输入一次项系数")
b = InputBox("b", "输入二次项系数")
c = InputBox("c", "输入常数")
If b ^ 2 - 4 * a * c >= 0 Then
x = (-b + Sqr(b ^ 2 - 4 * a * c)) / 2 * a
y = (-b - Sqr(b ^ 2 - 4 * a * c)) / 2 * a
If x = y Then
Print "x1=x2="; "-"; b; "±"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; x
Else
Print "x1="; "-"; b; "+"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; x; "x2="; "-"; b; "-"; "根号"; b ^ 2 * 4 * a * c; "/"; 2 * a; "="; y
End If
Else
Print "方程无实数根"
End If
Else
End
End If
ok,有神马不懂得请留言