vb解二次函数代码问题!代码如下Private Sub Command1_Click()Dim a As Single,b As Single,c As SingleDim n As Single,m As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)If b ^ 2 - 4 * a * c < 0 ThenLabel3.Caption = "无解"Els
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/20 10:35:09
vb解二次函数代码问题!代码如下Private Sub Command1_Click()Dim a As Single,b As Single,c As SingleDim n As Single,m As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)If b ^ 2 - 4 * a * c < 0 ThenLabel3.Caption = "无解"Els
vb解二次函数代码问题!
代码如下
Private Sub Command1_Click()
Dim a As Single,b As Single,c As Single
Dim n As Single,m As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If b ^ 2 - 4 * a * c < 0 Then
Label3.Caption = "无解"
Else
n = -b + (b ^ 2 - 4 * a * c) ^ (1 / 2) / 2 * a
m = -b - (b ^ 2 - 4 * a * c) ^ (1 / 2) / 2 * a
Label3.Caption = "" + CStr(n) + " " + CStr(m) + ""
End If
End Sub
请问 哪错了?
vb解二次函数代码问题!代码如下Private Sub Command1_Click()Dim a As Single,b As Single,c As SingleDim n As Single,m As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)If b ^ 2 - 4 * a * c < 0 ThenLabel3.Caption = "无解"Els
一、你没有考虑a=0 的情况
二、n= 和m= 这两句,你要把 2*a 用() 括起来做分母 或者你把 * 号,换成除号 / 就不用括起来了!
还有楼上说的,分子也要括起来!哈哈