题目
如何用VB求一元二次方程的虚数解(一定是虚数解).
提问时间:2020-10-28
答案
解一元二次方程的Vb程序:
在窗体上画一个命令按钮,输入下列代码,运行后可在窗体打印结果.
Private Sub Command1_Click()
dim a as double,b as double ,c as double,x as string
a=inputbox("请输入系数a:")
b=inputbox("请输入系数b:")
c=inputbox("请输入系数c:")
x=QuarEquation(a,b,c)
print x
end sub
printe function QuarEquation(byval a as double,byval b as double,byval c as double) as string
dim a as double,b as double ,c as double,P as double
dim xr as double ,xi as double ,x as string,xp as double
dim x1 as string,x2 as string,hh as string
hh=chr(13)+chr(10)
xr=-b/2
p=b^2-4*a*c
select case p
case is >0
xp=sqr(P)/2
x1=xr+xp
x2=xr-xp
x="x1=" & x1 & ";" & hh "x2=" & x2
QuarEquation=x
case is = 0
x="x1=x2=" &xr
QuarEquation=x
case is
在窗体上画一个命令按钮,输入下列代码,运行后可在窗体打印结果.
Private Sub Command1_Click()
dim a as double,b as double ,c as double,x as string
a=inputbox("请输入系数a:")
b=inputbox("请输入系数b:")
c=inputbox("请输入系数c:")
x=QuarEquation(a,b,c)
print x
end sub
printe function QuarEquation(byval a as double,byval b as double,byval c as double) as string
dim a as double,b as double ,c as double,P as double
dim xr as double ,xi as double ,x as string,xp as double
dim x1 as string,x2 as string,hh as string
hh=chr(13)+chr(10)
xr=-b/2
p=b^2-4*a*c
select case p
case is >0
xp=sqr(P)/2
x1=xr+xp
x2=xr-xp
x="x1=" & x1 & ";" & hh "x2=" & x2
QuarEquation=x
case is = 0
x="x1=x2=" &xr
QuarEquation=x
case is
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1水绵的结构图是怎样的?
- 2常见元素所有化合价,包括不常见的价位
- 3英语翻译
- 4在高锰酸钾和锰酸钾中下列描述正确的是 a元素的化合价相同 b还有相同价态的原子团 C含有不同
- 5已知A=a+2,B=a²-a+5,C=a²+5a-19,其中a>2.指出A与C哪个大,并说明理由
- 6期末考~急culture,pollution,death,success,cookie,society,customer,cooker,occasion哪些可数?
- 7完成下列句子
- 8求1.204×10^23个CH4分子中含有C原子的物质的量?含有氢原子的个数是多少?
- 9肝脏细胞中,含量最多的化合物是( ) A.胆汁 B.水 C.肝糖元 D.蛋白质
- 10the great wall is one of_________in the world
热门考点