求教,求帮助编写一个一元二次方程求根的VB程序,自己弄了好多遍都不对,求教,急,拜托高手们了,谢谢!

如题所述

初中的数学知识,你按照解方程的步骤,用VB代码实现就是了。
Private Sub Command1_Click()
dim a as single,b as single,c as single
dim d as single
dim x1 as single,x2 as single
a = text1.text
b = text2.text
c = text3.text
d = b*b - 4*a*c
if d>=0 then
x1 = (-b + sqr(d))/2/a

x2 = (-b - sqr(d))/2/a
text4.text=x1
text5.text=x1
else
msgbox "无实数解!"
end if
End Sub
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-04-11
键入根
根的类型为布尔

根单

小根单

功能求根(单,B为单,C如单)作为根型

昏暗的塔单

塔= B ^ 2-4 * A * C

如果太塔<0,则发现根部有根=假:“退出”功能 BR />塔= SQR(太塔)

根求根=(B +塔)/(2 *)

根寻根=(-B-塔)/(2 *)
端功能
第2个回答  2013-04-11
键入根
根的类型为布尔

根单

小根单

功能求根(单,B为单,C如单)作为根型

昏暗的塔单

塔= B ^ 2-4 * A * C

如果太塔<0,则发现根部有根=假:“退出”功能 BR />塔= SQR(太塔)

根求根=(B +塔)/(2 *)

根寻根=(-B-塔)/(2 *)
端功能
第3个回答  2013-03-21
Private Sub Command1_Click()
Dim a#, b#, c#, d#, x1#, x2#
a = Val(InputBox("a=", "数据输入框", 1))
b = Val(InputBox("b=", "数据输入框", 2))
c = Val(InputBox("c=", "数据输入框", 1))
If a = 0 Then
If b = 0 Then
If c = 0 Then Print "解得:x有无穷解" Else Print "x无解"
Else
Print "解得:x=" & -c / b
End If
Else
d = b * b - 4 * a * c
If d > 0 Then
x1 = (-b + Sqr(d)) / (2 * a)
x2 = (-b - Sqr(d)) / (2 * a)
Print "解得:x1=" & x1,
Print "x2=" & x2
Else
x1 = -b / (2 * a)
If d = 0 Then Print "解得:x=" & x1
If d < 0 Then
Print "无实根"
End If
End If
End If
End Sub

“求一元二次方程的根”的vb代码怎么写,跪求,谢谢
Private Sub Command1_Click()a = Val(Text1) '文本框里的值取出来b = Val(Text2) '分别存到三个变量里,做方程的系数c = Val(Text3)If a <> 0 Then '首先判断第一个系数不为0 的情况 dt = b ^ 2 - 4 * a * c '公式中用到的表达式暂存 r = -b \/ (2 * ...

“求一元二次方程的根”的vb代码怎么写,跪求
Private Sub Command1_Click()GetX 1, 2, 1 End Sub '===求一元二次方程的根=== Sub GetX(a As Double, b As Double, c As Double)Dim d As Double d = b ^ 2 - 4 * a * c If d > 0 Then MsgBox "次方程有两个根:" & vbCrLf & "x1=" & (-b + d) \/ (2 * ...

一元二次方程求根公式式如何用VB程序编辑
function 求根(a as single,b as single,c as single) as 根类型 dim 得塔 as single 得塔=b^2-4*a*c if 得塔<0 then 求根.有根=false:exit function 得塔=sqr(得塔)求根.大根=(-b+得塔)\/(2*a)求根.小根=(-b-得塔)\/(2*a)end function ...

如何利用vb制作一元二次方程求根系统?
启动VB编程程序。可以到官方网上下载visual basic程序,然后进行安装,安装结束,双击打开程序,新建一个工程。设计求根系统面板。这个面板由6个标签控件,6个文本框和两个命令按钮组成。单击标签控件A,在form面板上插入6个标签。命名标签。右击标签1,打开属性窗口。把标签名称改为a,同样的把标签2,3,,...

VB的编程求一元二次方程的根
第二种,系数a、b、c及方程的根都采用对话框方式输入、输出;代码如下:'对话框输入输出法Private Sub Command1_Click() Dim a As Single, b As Single, c As Single Dim delta As Single, x1 As Single, x2 As Single a = Val(InputBox("输入一元二次方程系数a")) If a ...

vb一元二次方程求实根虚根程序
Private Sub Command1_Click() Dim a As Single, b As Single, c As Single, d As Single Label8.Caption = "" Label9.Caption = "" a = Val(Text1.Text): b = Val(Text2.Text): c = Val(Text3.Text) d = b ^ 2 - 4 * a * c If d = 0 Then Label8.Ca...

用VB怎么编一元二次方程计算?
val(text3.text)=c '给变量赋值 if b^2-4ac>=0 then x1=(-b+sqr(b^2-4ac))\/2a x2=(-b-sqr(b^2-4ac))\/2a '利用求根公式计算 print "方程的解为:" & x1 & ";" & x2 else print "方程没有实数解"end if '判断并输出结果 ...

VB 解一元二次方程程序设计
一、按钮“求一元二次方程”的vb代码如下:Private Sub Command1_Click()a = Text1.Text b = Text2.Text c = Text3.Text d = b * b - 4 * a * c If d >= 0 Then X1 = (-b + Sqr(d)) \/ (2 * a)X2 = (-b - Sqr(d)) \/ (2 * a)Label4.Caption = X1 Label5...

vb解一元二次方程的代码,我的代码哪里错了?拜托各位了 3Q
", "求一元二次方程的根") b = InputBox("输入b的值:", "求一元二次方程的根") c = InputBox("输入c的值:", "求一元二次方程的根") X1 = (-b + Sqr(Abs(b ^ 2 - 4 * a * c))) \/ (2 * a) X2 = (-b - Sqr(Abs(b ^ 2 - 4 * a * c))) \/ (2 * ...

用vb编写一个一元二次方程
在窗口上新建一个按钮,代码如下:Private Sub Command1_Click()Dim a As Single Dim b As Single Dim c As Single Dim x As Single Dim y As Single a = Val(InputBox("请输入a", "参数a"))b = Val(InputBox("请输入b", "参数b"))c = Val(InputBox("请输入c", "参数c"))x...

相似回答