ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:101.29KB ,
资源ID:3453834      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3453834.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(轻轻松松学VB第一期自己动手做称手工具软件.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

轻轻松松学VB第一期自己动手做称手工具软件.docx

1、轻轻松松学VB第一期自己动手做称手工具软件轻轻松松学VB,第一期:自己动手做称手工具软件大家有没有在电子制作的时候一个公式要反复用好几遍,参数改好几次,计算更是想吐,现成的软件又不好找,要不就是用着不顺手,其实,大家可以学一点VB知识,就完全可以打造自己的计算工具。我在假期闲的无聊就练练手,自己动手做了几个小工具软件,在此我就抛砖引玉了,把制作过程及代码贴上来,欢迎大家拍砖。首先是熟悉VB的编程环境,就是常用VB6.0.这个相关只是就先暂不补充了,感兴趣的看看书半个小时就能上手。下面是其中的几个界面:2011-10-3 14:25:46 上传下载附件 (51.93 KB) 2011-10-3

2、14:25:57 上传下载附件 (31.66 KB) 2011-10-3 14:26:10 上传下载附件 (40.88 KB) 在计算电阻分压这一块关键的是协调数据使用条件,比如用一些提示信息来提醒你哪些必须输入哪些可以输入,这里我用了几个if语句解决的,代码有点笨,见谅。Private Sub Command1_Click()Dim a, b, c, d, e As Singlea = Val(Text2.Text)b = Val(Text3.Text)c = Val(Text1.Text)d = Val(Text4.Text)If Text1.Text And Text2.Text And

3、 Text3.Text And Text4.Text ThenMsgBox 请保证输入的数据只有三个已知量!, vbYes, 注意ElseIf d c And c 0 ThenMsgBox 请设置输入电压高于输出电压, vbYes, 注意ElseIf c = d 0 Thena = 0Text3.Text = Text2.Text = 0ElseIf Text2.Text = Thene = b * (c - d) / dText2.Text = eElseIf Text3.Text = Thene = a * d / (c - d)Text3.Text = eElseIf Text1.Tex

4、t = Thene = d * (a + b) / bText1.Text = eElseIf Text4.Text = Thene = b * c / (a + b)Text4.Text = eEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = Text3.Text = Text4.Text = End SubPrivate Sub Command3_Click()MsgBox 本工具由小猛为结婚的电感制作,版权没有,翻版不究,本计算为知三

5、求一形式,输入变量时请输入三个,再次计算请先清除或者保证一个变量为空,输入电压务必大于输出电压。数值为单精度,正数范围在1.401298E-45到3.402823E38之间,不填写数值默认为0, vbYes + 0, 工具说明End SubPrivate Sub Command4_Click()EndEnd Sub习惯不好,没加注释,大家忍着看吧,是不是感觉重复的语句很多,其实就这么简单,不用很牛B的句子,毕竟咱们是玩电的,不是专业程序员。下面说一下解方程的。这个一般的程序书上算法都有。话不多说,直接上代码:Private Sub Command1_Click()Form1.ShowForm2

6、.HideEnd SubPrivate Sub Command2_Click()Dim a As Single, b As Single, c As Single Dim D As Single, X1 As Single, X2 As Single Dim R As Single, P As Single a = Val(Text1.Text) 取数据a b = Val(Text2.Text) 取数据b c = Val(Text3.Text) 取数据c If a = 0 Then 当a=0 Text4.Text = 不是二次方程 Text5.Text = 不是二次方程 Else a0 D =

7、 b * b - 4 * a * c R = -b / (2 * a)If D = 0 Then D=0 Text4.Text = R Text5.Text = R ElseIf D 0 Then D0X1 = (-b + Sqr(D) / (2 * a) X2 = (-b - Sqr(D) / (2 * a) Text4.Text = X1 Text5.Text = X2 Else D0P = Sqr(-D) / (2 * a) Text4.Text = R & + & P & i Text5.Text = R & - & P & i End If End IfEnd SubPrivate

8、Sub Command3_Click()Text1.Text = Text2.Text = Text3.Text = Text4.Text = Text5.Text = End SubPrivate Sub Command4_Click()Dim a1, b1, c1, m1, n1, t1, x11, y11 As Singlea1 = Val(Text6.Text)b1 = Val(Text7.Text)c1 = Val(Text8.Text)m1 = Val(Text10.Text)n1 = Val(Text11.Text)t1 = Val(Text12.Text)If Text6.Te

9、xt And Text7.Text And Text8.Text And Text10.Text And Text11.Text And Text12.Text And Text6.Text Text10.Text And Text7.Text Text11.Text Theny11 = (m1 * c1 - a1 * t1) / (a1 * n1 - b1 * m1)x11 = (-c1 - b1 * y11) / a1Text9.Text = x11Text13.Text = y11ElseIf Text6.Text = Text10.Text Or Text7.Text = Text11

10、.Text ThenMsgBox 不为二元方程组!, vbYes, 注意ElseIf Text6.Text = Or Text7.Text = Or Text8.Text = And Text10.Text = Or Text11.Text = Or Text12.Text = ThenMsgBox 请保证输入数据的完整性!, vbYes, 注意End IfEnd IfEnd IfEnd SubPrivate Sub Command5_Click()Text6.Text = Text7.Text = Text8.Text = Text9.Text = Text10.Text = Text11.

11、Text = Text12.Text = Text13.Text = End Sub大家慢慢看吧下面就把波形绘制的贴出来,主要实现方法就是峰值叠加跟折线描图,大家都懂得,废话我就不多说了Option ExplicitConst Pi As Single = 3.14159265358979Dim a()As Single, b() As Single, c() As SingleDim YMax As Single, AZero As BooleanDim w As Integer, h, aa As IntegerSub Drawsin(a As Single, b As Single, c

12、 As Single) Dim iAs Integer, x As Single, y As Single, j As Single Dim oi As Single, oj As Single For i = 0 To w Step 1 x = i / w * 6 * Pi y = a * Sin(b * x + c) j = -h * (y - YMax) / (2 * YMax) If i = 0 Then Picture1.PSet (i, j), RGB(255, 0, 0) Else Picture1.Line (oi, oj)-(i, j), RGB(255, 0, 0) End

13、 If oi = i oj = j NextEnd SubSub Drawaaddsin() Dim iAs Integer, x As Single, y As Single, j As Single Dim oi As Single, oj As Single Dim kAs Integer For i = 0 To w Step 1 x = i / w * 6 * Pi y = 0 For k = 1 To UBound(a) y = a(k) * Sin(b(k) * x + c(k) + y Next j = -h * (y - YMax) / (2 * YMax) If i = 0

14、 Then Picture2.PSet (i, j), RGB(0, 0, 255) Else Picture2.Line (oi, oj)-(i, j), RGB(0, 0, 255) End If oi = i oj = j NextEnd SubSub DrawXY() With Picture1 Picture1.Line (0, h / 2)-(w, h / 2) Picture1.Line (0, 0)-(0, h) .CurrentX = 0 .CurrentY = h / 2 Picture1.Print 0 .CurrentX = w / 3 .CurrentY = h /

15、2 Picture1.Print 2 .CurrentX = 2 * w / 3 .CurrentY = h / 2 Picture1.Print 4 .CurrentX = w - 15 .CurrentY = h / 2 Picture1.Print 6 End WithWith Picture2 Picture2.Line (0, h / 2)-(w, h / 2) Picture2.Line (0, 0)-(0, h) .CurrentX = 0 .CurrentY = h / 2 Picture2.Print 0 .CurrentX = w / 3 .CurrentY = h / 2

16、 Picture2.Print 2 .CurrentX = 2 * w / 3 .CurrentY = h / 2 Picture2.Print 4 .CurrentX = w - 15 .CurrentY = h / 2 Picture2.Print 6 End WithEnd SubPrivate Sub Command1_Click() Dim i As Integer If Val(Text1.Text) = 0 Then AZero = True Else ReDim Preserve a(UBound(a) + 1) ReDim Preserve b(UBound(b) + 1)

17、ReDim Preserve c(UBound(c) + 1) a(UBound(a) = Val(Text1.Text) b(UBound(b) = Val(Text2.Text) c(UBound(c) = Val(Text3.Text) YMax = YMax + Abs(a(UBound(a) Picture1.Cls Picture2.Cls DrawXY For i = 1 To UBound(a) Drawsin a(i), b(i), c(i) Next Drawaaddsin End If Text5.Text = YMax aa = aa + 1 Text4.Text =

18、aa If AZero Then Picture1.Line (0, h / 2)-(w, h / 2), RGB(255, 0, 0) Picture2.Line (0, h / 2)-(w, h / 2), RGB(255, 0, 0) End SubPrivate Sub Command2_Click() Picture1.ClsPicture2.Cls Form_Load Text1.Text = Text2.Text = Text3.Text = Text5.Text = End SubPrivate Sub Command3_Click()Form1.ShowForm111.Hid

19、eEnd SubPrivate Sub Form_Load() ReDim a(0), b(0), c(0) YMax = 0 aa = 0 AZero = False With Picture1 .AutoRedraw = True .ScaleMode = vbPixels w = .ScaleWidth h = .ScaleHeight End WithWith Picture2 .AutoRedraw = True .ScaleMode = vbPixels w = .ScaleWidth h = .ScaleHeight End With DrawXY Text4.Text = 0End Sub

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1