题目
如何用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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1complete the sentences with the words in the box怎么翻译
- 2There are lots of lockers____the students.
- 3二进制数1110 0111 1010 1001对应的十六进制数是
- 4宇宙除了太阳可以提供光和热量,还有其他星球能吗
- 5几道数学题.①关于X的一元二次方程x²-3x-k=0有两个不相等的实数根 (1)
- 6世界上第一部反不正当竞争法是美国的《谢尔曼法》还是德国的《反不正当竞争法》?
- 7gliese581其宏观分子原子结构,在宇宙上貌似和地球一样.
- 8People will wear___ when it is cold outside.(scarf)
- 9从甲地到乙地,小红用了四小时,小明用了3小时,小红的速度比小明慢多少%
- 10六年级上册语文第九课穷人读后感言
热门考点
- 1白云宾馆在装修时,准备在主楼梯上铺上红地毯.已知这种地毯每平方米售价30元,主楼梯宽2米,其侧面如右图所示,则购买这种地毯至少需要_元.
- 2各个数位上的数字的和( ),而且个位上是( )的数,才既是2的倍数,又是3的倍数.
- 3五柳先生传中所用的四个典故 是哪四个?
- 4在生活中,那些是热的良导体?哪些是不良导体!多一点
- 5蓝鲸每小时可以游60千米,比海豚的速度还慢1/7.海豚每小时可以游多少千米?
- 6Steel 什么标准?
- 7一个分数化成最简分数是五分之二.这个分数约分前,分子比分母小18.那么,约分时约的最大公因数是几?
- 8如果多项式 x的四次方-(a-1)x的三次方+5x的二次方-(b+3)x-1不含x的三次方与x项,求ab
- 9you can play fooball or fly kites there什么意思
- 10已知函数f(x)=2x+3,数列{an}满足a1=1,且a(n+1)=f(an),则该数列的通项公式是—— (a后面的都是下标)