Private Sub Command1_Click()
Dim a!, b!, c!, x1!, x2!, disc!
a = Val(Text1)
b = Val(Text4)
c = Val(Text3)
disc = b * b - 4 * a * c
If Text1 < -20 Or Text1 > 20 Or Text4 < -20 Or Text4 > 20 Or Text3 < -20 Or Text3 > 20 Then
MsgBox "超出范围 请在0-20内输入", 2 + vbExclamation, "错误提示"
Else
If a = 0 Then
x = Text3 / -Text4
Text2.Visible = False
Text5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label3.Visible = True
Text6.Visible = True
Label1.Visible = True
Label8.Visible = False
Text6.Text = Str$(x)
Else
If disc > 0 Then
x1 = (-b + Sqr(disc)) / (2 * a)
x2 = (-b - Sqr(disc)) / (2 * a)
Label1.Visible = True
Label8.Visible = False
Label7.Visible = True
Label6.Visible = True
Text5.Visible = True
Text2.Visible = True
Text2.Text = Str$(x1)
Text5.Text = Str$(x2)
ElseIf disc = 0 Then
x = (-b) / (2 * a)
Text2.Visible = False
Text5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label3.Visible = True
Text6.Visible = True
Label1.Visible = True
Label8.Visible = False
Text6.Text = Str$(x)
Else
Label8.Visible = True
End If
End If
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Label8.Visible = False
Label7.Visible = False
Label6.Visible = False
Label1.Visible = False
Text2.Visible = False
Text5.Visible = False
Label3.Visible = False
Text6.Visible = False
End Sub
Private Sub Form_Load()
Label6.Visible = False
Text2.Visible = False
Label3.Visible = False
Text6.Visible = False
Label1.Visible = False
Label7.Visible = False
Text5.Visible = False
Label8.Visible = False
End Sub
这个算出来的答案怎么老是不对?
高手们帮忙解决哈!谢谢
如何利用vb制作一元二次方程求根系统?
启动VB编程程序。可以到官方网上下载visual basic程序,然后进行安装,安装结束,双击打开程序,新建一个工程。设计求根系统面板。这个面板由6个标签控件,6个文本框和两个命令按钮组成。单击标签控件A,在form面板上插入6个标签。命名标签。右击标签1,打开属性窗口。把标签名称改为a,同样的把标签2,3,,...
一元二次方程计算机解
在VB编程中,可以使用以下代码来实现一元二次方程的求解。这个代码适用于一般形式的一元二次方程 ax^2 + bx + c = 0,并会以对话框的形式显示解的结果。首先,需要定义变量a、b和c,以及可能的解x1和x2,例如:vbDim a As Double, b As Double, c As Double, x1 As Double, x2 As Do...
VB6.0实现一元二次方程的求解
打开VB6.0,新建一个工程,在窗体中添加两个命令按钮,caption分别改为“计算”、“输出”,将窗体Form1的caption属性改为“解一元二次方程”,添加5个标控件,将其caption属性分别改为“a”、"b”、“c”、“X1”、“X2”,添加5个文本框,并将其Text属性清空,将界面设置成下图 一元二次...
VB编一元二次方程
MsgBox "此方程无实数根", 0, "错误"Text1.Text = ""Text2.Text = ""Text3.Text = ""Exit Sub ElseIf A = 0 Then MsgBox "二次项系数不能为0", 0, "错误"Else IntSqr Pbs, PbsZs, PbsXs MsgBox "X1=〔" & -B & "+" & PbsZs & PbsXs & " 〕\/" & (2 * A) & C...
VB6.0一元二次方程计算器怎么让计算结果保留根号与分数
Private Sub Command1_Click()'“x2-8x+1=0”答案是4+根号15 与 4-根号15。Dim A As Double A = Text1.Text Dim B As Double B = Text2.Text Dim C As Double C = Text3.Text Dim D As Double D = B ^ 2 - 4 * A * C If D < 0 Then MsgBox ("此题无实数解"): ...
vb一元二次方程,要求有函数图像。不会编,有没有大佬会做,在线等挺急...
只含有一个未知数(一元),并且未知数项的最高次数是2(二次)的整式方程叫做一元二次方程。标准形式为:ax²+bx+c=0(a≠0)。其中ax²是二次项,a是二次项系数;bx是一次项;b是一次项系数;c是常数项。使方程左右两边相等的未知数的值就是这个一元二次方程的解,一元二次...
用VB编写求一元二次方程的代码是什么?
'求一元二次方程的跟ax^2+bx+c=0 Private Sub Command1_Click()Dim a#, b#, c#, gen a = InputBox("输入A的值")b = InputBox("输入B的值")c = InputBox("输入C的值")If a = 0 And b = 0 And c = 0 Then Print "x的值是全体实数."ElseIf a = 0 And b = 0 And ...
如何用VB求一元二次方程的虚数解(一定是虚数解)。
vb代码如下:Private Sub Command1_Click()Dim a As Single, b As Single, c As Single Dim d As Single, x1 As Single, x2 As Single a = InputBox("请输入一元二次方程的系数a")b = InputBox("请输入一元二次方程的系数b")c = InputBox("请输入一元二次方程的系数c")If a = ...
求解一道VB题:输入一元二次方程的系数a,b,c的值,编程求解一元二次方程a...
Dim a As Single, b As Single, c As Single, t As Double a = Val (Text1.Text) b = Val (Text2.Text)。含义及特点:(1)一元二次方程的解(根)的意义:能使一元二次方程左右两边相等的未知数的值称为一元二次方程的解。一般情况下,一元二次方程的解也称为一元二次方程的...
VB解一元二次方程
Private Sub Command1_Click()a = Val(Text1, Text) Text1, Text中间是.不是,b = Val(Text2, Text) 同样 c = Val(taxt3, Text) 同样 X1 = Val(Text4, Text) 同样,这句删除!X2 = Val(Text5, Text) 同样,这句也删除!d = b ^ 2 - 4 * a * c If d > 0 Then X1 =...