(1)新建表单,添加4个标签,3个文本框,1个编辑框,1个命令按钮。在表单的初始化Form1.Init()写上如下的代码
ThisForm.Text1.Value=0
ThisForm.Text2.Value=0
ThisForm.Text3.Value=0
ThisForm.Text1.InputMask='9999999999.9999'
ThisForm.Text2.InputMask='9999999999.9999'
ThisForm.Text3.InputMask='9999999999.9999'
ThisForm.Edit1.Value=''
ThisForm.Edit1.ReadOnly=.T.
(2)Command1.Click()
a=ThisForm.Text1.Value
b=ThisForm.Text2.Value
c=ThisForm.Text3.Value
d=b*b-4*a*c
Do Case
Case a=0 And b=0 And c=0
lcString='恒等式,无穷多个根'
Case a=0 And b=0 And c#0
lcString='恒不等式,无解'
Case a=0 And b#0
lcString='一元一次方程,根为'+transform(-b/c)
Case d>0
lcString='一元二次方程,有两个不等实根,分别为'+transform((-b+sqrt(d))/(2*a))+'和'+transform((-b-sqrt(d))/(2*a))
Case d=0
lcString='一元二次方程,有两个相等实根,为'+transform(-b/(2*a))
Case d<0
lcString='一元二次方程,有共轭虚根,为'+transform(-b/(2*a))+'±'+transform(sqrt(-d)/abs(2*a))+'i'
EndCase
ThisForm.Edit1.Value=lcString