在窗体上分别放三个文本框用于输入a,b,c的值,再放一个按钮用于求解
private sub command1_click()
dim x as double,x1 as double,x2 as double,a1 as double,a2 as double
a =val(text1.text)
b =val(text2.text)
c =val(text3.text)
cls
currentx=600
currenty=1100
if a =0 then
if b =0 then
msgbox "系数为0,请重新输入!"
text1.setfocus
text1.selstart=0
text1.sellength=len(text1.text)
else
x=-c/b
print "x=";format(x,"0.000")
end if
exit sub
end if
dim n as double
n=b^2-4*a*c
select case n
case 0
print "x1=x2=";format(-b/(2*a),"0.000")
case is >0
x1=(-b+sqr(n)/(2*a)
x2=(-b-sqr(n)/(2*a)
print "x1=";format(x1,"0.000")
currentx=600
currenty=1300
print "x2=";format(x2,"0.000")
case is
猜你喜欢
- 1英语翻译
- 2是酒精喷灯加热快还是酒精灯上套一个金属网罩加热快?
- 3would you like to go to swim with us?中文 回答
- 4英语翻译
- 5你 说 他 不 说 [加上标点,使句子表达的意思不同]
- 6在1至301的所有奇数中,数字3共出现46次.
- 7已知函数f(x)=sinx(cosx-根号3sinx) 求f(x)的最小正周期
- 8如图在△ABC中,D是BC的中点,过点D的直线GF交AC于点F,交AC的平行线BG于点G,DE垂直GF,交AB于点E,连接EG,EF.
- 9my birthday is my favourite day of the year为什么是“of the year",而不是"of a year”?
- 10Zn.Cu和H2SO4组成的原电池的电极反应式 负极:正极: