怎样用VB做出这到题 方程ax2+bx+c=0 要求根据a b c系数的变化求出方程的根Private Sub Command1_Click()Dim pbs As Singlepbs = b * b - 4 * a * cIf pbs > 0 Thenpbs = Sqr(pbs)Text4 = Format((-b + pbs) / 2 / a,"0.00")Text5 = Format((-b
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 00:41:03
怎样用VB做出这到题 方程ax2+bx+c=0 要求根据a b c系数的变化求出方程的根Private Sub Command1_Click()Dim pbs As Singlepbs = b * b - 4 * a * cIf pbs > 0 Thenpbs = Sqr(pbs)Text4 = Format((-b + pbs) / 2 / a,"0.00")Text5 = Format((-b
怎样用VB做出这到题 方程ax2+bx+c=0 要求根据a b c系数的变化求出方程的根
Private Sub Command1_Click()
Dim pbs As Single
pbs = b * b - 4 * a * c
If pbs > 0 Then
pbs = Sqr(pbs)
Text4 = Format((-b + pbs) / 2 / a,"0.00")
Text5 = Format((-b - pbs) / 2 / a,"0.00")
ElseIf pbs = 0 Then
Text4 = Format(-b / 2 / a,"0.00")------有哪位大哥能告诉我这步是哪里错了,本人感激不尽!
Text5 = Format(-b / 2 / a,"0.00")
Else
pbs = Sqr(-pbs)
Text4 = Format((-b + pbs) / 2 / a,"0.00") + "+i"
Text5 = Format((-b + pbs) / 2 / a,"0.00") + "-i"
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_Change()
If Text1 "" And Not IsNumeric(Text1) Then
Text1 = ""
Text1.SetFocus
Else
a = Text1
End If
End Sub
Private Sub Text2_Change()
If Text2 "" And Not IsNumeric(Text2) Then
Text2 = ""
Text2.SetFocus
Else
b = Text2
End If
End Sub
Private Sub Text3_Change()
If Text3 "" And Not IsNumeric(Text3) Then
Text3 = ""
Text3.SetFocus
Else
b = Text3
End If
End Sub
我到底错在哪里呀
小弟感激万分
怎样用VB做出这到题 方程ax2+bx+c=0 要求根据a b c系数的变化求出方程的根Private Sub Command1_Click()Dim pbs As Singlepbs = b * b - 4 * a * cIf pbs > 0 Thenpbs = Sqr(pbs)Text4 = Format((-b + pbs) / 2 / a,"0.00")Text5 = Format((-b
你这样做太烦琐
这样更简洁些:
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim z As Single
Dim x1 As Single
Dim x2 As Single
a = Text1.Text
b = Text2.Text
c = Text3.Text
z = b ^ 2 - 4 * a * c
If a = 0 Then
If b = 0 And c = 0 Then
Text4 = "无穷解"
Text5 = "无穷解"
ElseIf b = 0 Then
Text4 = "无解"
Text5 = "无解"
Else
x1 = -c / b
Text4 = x1
Text5 = "无解"
End If
我VB没有学过,学的是其他语言,但这题目也做到过,用求跟公式来做就可以,好像不是很麻烦……
算出△,确定是正是负还是0
分三种情况:
1,正:两个根,套用公式计算
2,负:无解
3,零:两根相等,用公式计算
不同语言殊途同归,鄙人只能提供这些帮助,不知是否有用,建议这位兄弟到“电脑/网络 ---- 编程”中去提问,那里有一些高手,应该能比我更...
全部展开
我VB没有学过,学的是其他语言,但这题目也做到过,用求跟公式来做就可以,好像不是很麻烦……
算出△,确定是正是负还是0
分三种情况:
1,正:两个根,套用公式计算
2,负:无解
3,零:两根相等,用公式计算
不同语言殊途同归,鄙人只能提供这些帮助,不知是否有用,建议这位兄弟到“电脑/网络 ---- 编程”中去提问,那里有一些高手,应该能比我更好解答你的问题
收起
8懂