# *主程序的调用中errors总是不为"".这是为什么呢？

very2773029 2004-09-27 04:48:24
*主程序的调用中errors总是不为"".这是为什么呢？
CLEAR
SET TALK OFF

INPUT "请输入一元二次方程的系数A：" TO A
INPUT "请输入一元二次方程的系数B：" TO B
INPUT "请输入一元二次方程的系数C：" TO C
DO Result WITH A, B, C

IF errors <> ""
?errors
ELSE
?"一元二次方程的根为：x1 = ", ltrim(str(x1)), " x2 = ", ltrim(str(x2))
ENDIF

SET TALK ON
RETURN

PROCEDURE Result
PARAMETER A, B, C
PUBLIC x1
PUBLIC x2
PUBLIC errors
errors = ""
x1 = 0
x2 = 0
b24ac = B^2 - 4 * A * C
IF b24ac >= 0
x1 = (-B + SQRT(B^2 - 4 * A * C))/2 * A
x2 = (-B - SQRT(B^2 - 4 * A * C))/2 * A
ELSE
errors = "B平方减4乘A乘C的值小于零，所以不能开根号！"
ENDIF
RETURN
...全文
57 4 打赏 收藏 举报

4 条回复

LAIYANGPJ 2004-09-28
• 打赏
• 举报

IF errors <> ""
?errors
ELSE
?"一元二次方程的根为：x1 = ", ltrim(str(x1)), " x2 = ", ltrim(str(x2))
ENDIF

IF errors == ""
?"一元二次方程的根为：x1 = ", ltrim(str(x1)), " x2 = ", ltrim(str(x2))
ELSE
?ERRORS
ENDIF

?errors
ELSE
?"一元二次方程的根为：x1 = ", ltrim(str(x1)), " x2 = ", ltrim(str(x2))
ENDIF

dfwxj 2004-09-28
• 打赏
• 举报

dfwxj 2004-09-27
• 打赏
• 举报

Hewiit 2004-09-27
• 打赏
• 举报

2574

VFP，是Microsoft公司推出的数据库开发软件，用它来开发数据库，既简单又方便。

2004-09-27 04:48