- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
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.Caption = Label3.Caption x e = f
End If
您可能关注的文档
最近下载
- 高边坡专项施工方案(专家论证版).pdf VIP
- 《工程化学基础》教案-第3章-2011.ppt VIP
- 抗日英雄王二小.pptx VIP
- 第5课 用发展的观点看问题-【中职专用】2024年中职思想政治《哲学与人生》金牌课件(高教版2023·基础模块).pptx VIP
- 老友记台词剧本第一季第1集中英双语左右对照.pdf VIP
- 形势与政策社会实践报告模板.docx VIP
- 全套SPC表格(很全面) CPK.xls VIP
- T_CI 540-2024 红枣蒸馏酒生产技术规程.pdf
- 施工组织设计方案(高速公路通信迁改).docx VIP
- Part3-4 Unit6 Craftsmanship课件高一英语(高教版基础模块2).pptx
文档评论(0)