如何用vb设计计算二次方程的根的程序Private Sub Command1_Click()Dim a As Single,b As Single,c As Single,d As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)d = b ^ 2 - 4 * a * cIf d > 0 ThenLabel8.Caption = (-b + Sqr(d))
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 07:23:00
如何用vb设计计算二次方程的根的程序Private Sub Command1_Click()Dim a As Single,b As Single,c As Single,d As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)d = b ^ 2 - 4 * a * cIf d > 0 ThenLabel8.Caption = (-b + Sqr(d))
如何用vb设计计算二次方程的根的程序
Private Sub Command1_Click()
Dim a As Single,b As Single,c As Single,d As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = b ^ 2 - 4 * a * c
If d > 0 Then
Label8.Caption = (-b + Sqr(d)) / (2 * a)
Label10.Caption = (-b - Sqr(d)) / (2 * a)
Else
If d = 0 Then
Label8.Caption = -b / (2 * a)
Label9.Caption = -b / (2 * a)
Else
If d < 0 Then
tl = MsgBox("无实数根!",vbOKOnly + vbExclamation,"系统提示")
End If
End Sub
帮忙看看哪里出错了?
如何用vb设计计算二次方程的根的程序Private Sub Command1_Click()Dim a As Single,b As Single,c As Single,d As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)d = b ^ 2 - 4 * a * cIf d > 0 ThenLabel8.Caption = (-b + Sqr(d))
elseif连起来就行了
Private Sub Command1_Click()
Dim a As Single,b As Single,c As Single,d As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = b ^ 2 - 4 * a * c
If d > 0 Then
Label8.Caption = (-b + Sqr(d)) / (2 * a)
Label10.Caption = (-b - Sqr(d)) / (2 * a)
ElseIf d = 0 Then
Label8.Caption = -b / (2 * a)
Label9.Caption = -b / (2 * a)
ElseIf d < 0 Then
tl = MsgBox("无实数根!",vbOKOnly + vbExclamation,"系统提示")
End If
End Sub