编程计算一元二次方程的解 vbPrivate Sub Command1_Click() '此程序在点击按钮Command1中完成*** a As ***,b As ***,c As *** '定义变量a、b、c为长整型数*** d As Single '定义变量d为单精度实型数*** x1 As Single,x2 A
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 13:13:12
编程计算一元二次方程的解 vbPrivate Sub Command1_Click() '此程序在点击按钮Command1中完成*** a As ***,b As ***,c As *** '定义变量a、b、c为长整型数*** d As Single '定义变量d为单精度实型数*** x1 As Single,x2 A
编程计算一元二次方程的解 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
求大侠改下 跪谢
编程计算一元二次方程的解 vbPrivate Sub Command1_Click() '此程序在点击按钮Command1中完成*** a As ***,b As ***,c As *** '定义变量a、b、c为长整型数*** d As Single '定义变量d为单精度实型数*** x1 As Single,x2 A
dim a as long
dim b as long
dim c as long
dim d as single
x1,x2也是dim(定义变量一般都是用dim)
d=b^2-4ac
if