第1个回答 2008-05-02
<script language="VBScript">
dim a,b,c,k
a=cint(inputbox("请输入a的值:"))
b=cint(inputbox("请输入b的值:"))
c=cint(inputbox("请输入c的值:"))
k=b*b-4*a*c
if k<0 then
document.write "方程无实解!"
elseif k=0 then
document.write "方程有一个解:"&-b/(2*a)
else
document.write "方程有两个解x1="&(-b+sqr(k))/(2*a)&" "&"x2="&(-b-sqr(k))/(2*a)
end if
</script>
第2个回答 2012-10-11
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, d As Single, f As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = b * b - 4 * a * c
If a <> 0 Then
If d > 0 Then
Text4.Text = (-b + Sqr(d)) / (2 * a)
Text5.Text = (-b - Sqr(d)) / (2 * a)
ElseIf d = 0 Then
Text4.Text = -b / (2 * a)
Text5.Text = -b / (2 * a)
Else
Text4.Text = -b / (2 * a) & "+" & Sqr(Abs(d)) / (2 * a) & "i"
Text5.Text = -b / (2 * a) & "-" & Sqr(Abs(d)) / (2 * a) & "i"
End If
Else
If b = 0 Then
MsgBox "方程无意义,请重新输入", 48, "输入错误"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Else
Text4.Text = -c / b
Text5.Text = -c / b
End If
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
,求加分啊朋友
第3个回答 2008-04-30
dim a ,b,c,x
a =val(inputbox("请输入系数a"))
b =val(inputbox("请输入系数b"))
c =val(inputbox("请输入系数c"))
……
让我想想先
第4个回答 2008-04-30
这个太容易了把...
d=b^2-4*a*c
判断d>0 =0 <0 就有多少个解
x1=(b^2+sqr(d))/2
x2=(b^2-sqr(d))/2