- 14
- 0
- 约7.56千字
- 约 9页
- 2017-05-12 发布于河南
- 举报
VB解一元二次方程配方法源码
VB解一元二次方程配方法
我也是一个vb的超级菜鸟,但是我运用我所学的数学知识,编辑了一个解一元二次方程的配方法过程的这么一个程序。我是自己原创,至于是不是首创就不知道了。(很多网上直接出答案的都是运用公式法计算的,那么我就想写个有过程的程序,完爆数学老师)
好了,废话不说多,现在先上测试图,有图有真相嘛。
这个程序有几个重点(后面源码都有注释)
a值要变为正数,否则将无法运行
开不尽的数要用根号表示,不会像√2=1.414……这么多小数
分母有理化,倒数第二步的分母不能为根号(标准)
移项时的符号注意变化。
下面是界面介绍:
下面直接上源码了,有注释自己可以理解。
Dim a$ ,b$,c$,d$,e$,f$,g$,h$
Dim jj!
Dim ii!
Dim pp!
Private Sub Command1_Click()
a = Text1.Text
b = Text2.Text
c = Text3.Text
d = Text4.Text
If a = 1 Then 第一步,先列出原式
Label3.Caption = x^2
End If
If a = -1 Then
Label3.Caption = -x^2
End If
If Not a = 1 And Not a = -1 Then
Label3.Caption = a x^2
End If
If b 0 Then
Label3.Caption = Label3.Caption + b
Else
Label3.Caption = Label3.Caption b
End If
If c 0 Then
Label3.Caption = Label3.Caption x+ c = d
Else
Label3.Caption = Label3.Caption x c = d
End If
If a 0 Then 当a为负数时,每个项同时乘以-1
a = -a
b = -b
c = -c
d = -d
End If
c = c - d 移项,将右边移向左边
If a = 0 Then 判断有无解
Label3.Caption = Label3.Caption vbCrLf 原方程无解
End If
If (b ^ 2) - (4 * a * c) 0 Then
Label3.Caption = Label3.Caption vbCrLf 原方程无解
End If
If a = 1 Then 第二步,写出移项后的结果
Label3.Caption = Label3.Caption vbCrLf x^2
End If
If a = -1 Then
Label3.Caption = Label3.Caption vbCrLf -x^2
End If
If Not a = 1 And Not a = -1 Then
Label3.Caption = Label3.Caption vbCrLf a x^2
End If
If b 0 Then
Label3.Caption = Label3.Caption + b
Else
Label3.Caption = Label3.Caption b
End If
If c 0 Then
Label3.Caption = Label3.Caption x+ c =0
Else
Label3.Caption = Label3.Caption x c =0
End If
e = (b ^ 2) / (4 * a) 算出适合配方的新c值
f = e - c 新c值与原c值的差,两边同时加差值
If a = 1 Then 第三步,写出初步配方的结果
Label3.Caption = Label3.Caption vbCrLf x^2
End If
If a = -1 Then
Label3.Caption = Label3.Caption vbCrLf -x^2
End If
If Not a = 1 And Not a = -1 Then
Label3.Caption = Label3.Caption vbCrLf a x^2
End If
If b 0 Then
Label3.Caption = Label3.Caption + b
Else
Label3.Caption = Label3.Caption b
End If
If e 0 Then
Label3.Caption = Label3.Caption x+ e = f
Else
Label3.
您可能关注的文档
- mt4 编程入门.doc
- MiniGUI在SKyEye0.8.6上的成功移植.doc
- MT4编程.doc
- MK CNET_CH6_PROGRAM1.doc
- Model-View-Controller.doc
- NCRE2.doc
- NCRE公共基础知识教案(第1章).doc
- NetBeans IDE 6.5 安装说明.doc
- Net程序设计2.doc
- New2010年秋研究生VB期末试卷.doc
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
原创力文档

文档评论(0)