组卷题库 > 初中信息技术试卷库
试题详情
窗体上有四个文本框Text1控件数组,两个按钮Command1和Command2。程序功能是解一个一元二次方程ax2+bx+c=0(a≠0)。程序运行后如图所示。给定的程序不完整,将程序补充完整。

Private Sub Command1_Click()

    Text1.Text = ""

    Text2.Text = ""

    Text3.Text = ""

    Text4.Text = ""

End Sub

Private Sub Command2_Click()

    Dim a As Single, b As Single, c As Single

    Dim x1 As Single, x2 As Single, det As Single

    a = Val(Text1.Text)

    b = Val(Text2.Text)

    c = Val(Text3.Text)

    det =      ‘(根的判别式b2-4ac)

    Select Case det

    Case Is > 0

        x1 = (-b + Sqr(det)) / (2 * a)

        x2 = (-b - Sqr(det)) / (2 * a)

        Text4.Text = "方程有两个实数根" & " x=" & Str(x1) & "   x=" & Str(x2)

    Case Is = 0

        Text4.Text = "方程有两个相等的实数根 x=" & Str(x1)

    Case

        Text4.Text = "此方程无实数根"

   

End Sub

知识点
参考答案
采纳过本试题的试卷
教育网站链接