首页 VB程序设计第三版实验C答案(全)

VB程序设计第三版实验C答案(全)

举报
开通vip

VB程序设计第三版实验C答案(全)VB程序设计第三版实验C答案(全) VB程序设计第三版实验C答案(全) 1 Private Sub Form_Click() Dim x!, y! x = Val(InputBox("输入x的值")) If x 150 Then y = 150 End If Print y End Sub 3 Private Sub Command1_Click() Dim x!, y!, z! x = InputBox("input x") y = InputBox("input y") z = ...

VB程序设计第三版实验C答案(全)
VB程序设计第三版实验C答案(全) VB程序设计第三版实验C答案(全) 1 Private Sub Form_Click() Dim x!, y! x = Val(InputBox("输入x的值")) If x < 1000 Then y = x ElseIf x < 2000 Then y = 0.9 * x ElseIf x < 3000 Then y = 0.8 * x Else y = 0.7 * x End If Print y End Sub 2 Private Sub Form_Click() Dim x!, y! x = Val(InputBox("输入上网时间")) If x < 10 Then y = 30 ElseIf x < 50 Then y = 30 + 2.5 * (x - 10) Else y = 30 + 2.5 * 40 + 2 * (x - 50) End If If y > 150 Then y = 150 End If Print y End Sub 3 Private Sub Command1_Click() Dim x!, y!, z! x = InputBox("input x") y = InputBox("input y") z = InputBox("input z") Print " x y z" Print " 排序前"; x; " "; y; " "; z If x < y Then t = x: x = y: y = t If x < z Then t = x: x = z: z = t If y < z Then t = y: y = z: z = t Print " 排序后" & x & " " & y & " " & z End Sub Private Sub Command2_Click() Dim x!, y!, z! x = InputBox("input x") y = InputBox("input y") z = InputBox("input z") Print " x y z" Print " 排序前"; x; " "; y; " "; z If x < y Then t = x: x = y: y = t If y < z Then t = y: y = z: z = t If x < y Then t = x: x = y: y = t End If End If Print " 排序后" & x & " " & y & " " & z End Sub 4 Dim a(3) As Integer Private Sub Command1_Click() Picture1.Cls For i = 0 To 2 a(i) = Int(Rnd * 100 + 200) Picture1.Print a(i) Next i End Sub Private Sub Command2_Click() Picture2.Cls Dim z As Integer For i = 0 To 1 If a(i) > a(i + 1) Then z = a(i + 1) a(i + 1) = a(i) a(i) = z End If Next i Picture2.Print a(0) Picture2.Print a(1) Picture2.Print a(2) End Sub 5 Private Sub Text2_LostFocus() Dim m%, n%, y% m = Val(Text1) n = Val(Text2) If n Mod 2 <> 0 Then MsgBox ("脚数必定为偶数") Text2 = "" Text2.SetFocus Else y = n / 2 - m If y < 0 Then MsgBox ("脚数必须?2倍的头数,请重新输入") Text2 = "" Text2.SetFocus Else x = n / 2 - m Label2 = y Label3 = m - y End If End If End Sub 6 Private Sub Command1_Click() Dim a!, b!, c!, x1!, x2!, de! a = Text1 b = Text2 c = Text3 de = b * b - 4 * a * c t = 2 * a If de = 0 Then Text4 = Format(-b / t, "0.00") Text5 = Format(-b / t, "0.00") ElseIf de > 0 Then Text4 = Format((-b + Sqr(de)) / t, "0.00") Text5 = Format((-b - Sqr(de)) / t, "0.00") Else Text4 = Format(-b / t, "0.00") & "+" & Format(Sqr(Abs(de)) / t, "0.00") & "i" Text5 = Format(-b / t, "0.00") & "-" & Format(Sqr(Abs(de)) / t, "0.00") & "i" End If End Sub Private Sub Command2_Click() Text1 = "" Text2 = "" Text3 = "" Text4 = "" Text5 = "" End Sub 7 Private Sub Text3_LostFocus() Select Case Trim(Text3) Case "+" Text4 = Val(Text1) + Val(Text2) Case "-" Text4 = Val(Text1) - Val(Text2) Case "*" Text4 = Val(Text1) * Val(Text2) Case "/" If Val(Text2) = 0 Then MsgBox "分母为零,重新输入" Text2 = "" Text2.SetFocus Else Text4 = Val(Text1) / Val(Text2) End If End Select End Sub 8 Private Sub Text1_LostFocus() Select Case Trim(Text1) Case 1 Text2 = "Monday" Case 2 Text2 = "Tuesday" Case 3 Text2 = "Wednesday" Case 4 Text2 = "Thursday" Case 5 Text2 = "Friday" Case 6 Text2 = "Saturday" Case 7 Text2 = "Sunday" Case Is > 7, Is < 1 MsgBox "数字为1~7,重新输入" Text1 = "" Text1.SetFocus End Select End Sub 或者 Private Sub Text1_LostFocus() If Text1 > 7 Or Text1 < 1 Then MsgBox "数字为1~7,重新输入" Text1 = "" Text1.SetFocus Else Text2 = Choose(Text1, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") End If End Sub
本文档为【VB程序设计第三版实验C答案(全)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_314871
暂无简介~
格式:doc
大小:21KB
软件:Word
页数:8
分类:生活休闲
上传时间:2017-10-17
浏览量:120