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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

VB课后答案.docx

1、VB课后答案第二章上机试题第一题Option ExplicitPrivate Sub Form_Load() Command2.Visible = False Command3.Visible = False Label2.Visible = FalseEnd SubPrivate Sub Command1_Click() Command1.Visible = False Text1.Visible = False Label1.Visible = False Label2.Visible = True Label2.AutoSize = True Label2.FontSize = 14 L

2、abel2.FontName = 黑体 Label2.ForeColor = vbRed Label2.Caption = Text1.Text & 同学,你好!祝你学好VB程序设计 Command2.Visible = True Command3.Visible = TrueEnd SubPrivate Sub Command2_Click() Command2.Visible = False Command3.Visible = False Label1.Visible = True Label2.Visible = False Command1.Visible = True Text1.

3、Visible = TrueEnd SubPrivate Sub Command3_Click() EndEnd SubPrivate Sub Label2_Click()End SubPrivate Sub Form_Load() 设置标签的初始位置及字号 Label1.Left = Form1.Width / 3 Label1.FontSize = 12End Sub第二题 Private Sub Command1_Click() 放 大 Label1.FontSize = Label1.FontSize * 3End SubPrivate Sub Command2_Click() 加 粗

4、 Label1.FontBold = TrueEnd SubPrivate Sub Command3_Click() 下画线 Label1.FontUnderline = TrueEnd SubPrivate Sub Command4_Click() 还原 Label1.Left = Form1.Width / 3 Label1.FontSize = 12 Label1.FontBold = False Label1.FontUnderline = FalseEnd SubPrivate Sub Command5_Click() 移 动 Dim dx As Single dx = Form1.

5、Width / 3 / 10 每次移动量是Label1最初距左边距离的1/10Label1.Left = Label1.Left dxEnd Sub第三章上机试题第二题 Private Sub Command1_Click() Label1.FontSize = Label1.FontSize * (Int(Rnd * 3 + 1) 放大字体 Label1.Caption = 当前时间为 & Time 显示时间 以下让Label1居中显示 Label1.Left = Form1.ScaleWidth / 2 - Label1.Width / 2 Label1.Top = Form1.Scale

6、Height / 2 - Label1.Height / 2End SubPrivate Sub Form_Load() Label1.Caption = 当前时间为 & Time Label1.Left = Form1.ScaleWidth / 2 - Label1.Width / 2 Label1.Top = Form1.ScaleHeight / 2 - Label1.Height / 2End Sub第三题Option ExplicitPrivate Sub Command1_Click()Label1.Caption = +Text3.Text = Val(Text1.Text) +

7、 Val(Text2.Text)End SubPrivate Sub Command2_Click()Label1.Caption = -Text3.Text = Val(Text1.Text) - Val(Text2.Text)End SubPrivate Sub Command3_Click()Label1.Caption = *Text3.Text = Val(Text1.Text) * Val(Text2.Text)End SubPrivate Sub Command4_Click()Label1.Caption = /Text3.Text = Val(Text1.Text) / Va

8、l(Text2.Text)End SubPrivate Sub Command5_Click()Text1.Text = Text2.Text = Text3.Text = Label1.Caption = End Sub第四章上机试题第一题Private Sub Text1_KeyPress(KeyAscii As Integer) Dim st As String * 1 st = Chr(KeyAscii) 小写字母与大写字母的Ascii码相差32 If st = a And st = A And st 0 Then MsgBox ( & x & , & y & ) 是在Y轴的上半轴上,

9、 vbInformation, 消息框 Else MsgBox ( & x & , & y & ) 是在Y轴的下半轴上, vbInformation, 消息框 End If Case Is 0 If y = 0 Then MsgBox ( & x & , & y & ) 是在X轴的正半轴上, vbInformation, 消息框 ElseIf y 0 Then MsgBox ( & x & , & y & ) 是在第一象限中, vbInformation, 消息框 Else MsgBox ( & x & , & y & ) 是在第四象限中, vbInformation, 消息框 End If

10、Case Is 0 Then MsgBox ( & x & , & y & ) 是在第二象限中, vbInformation, 消息框 Else MsgBox ( & x & , & y & ) 是在第三象限中, vbInformation, 消息 End If End Select End IfEnd Sub限定只能输入数字,逗号,回退键Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 按回车键调用判断命令按钮 Call Command1_Click Exit Sub End If Select Cas

11、e Chr(KeyAscii) Case 0 To 9, , -, Chr(8) Case Else KeyAscii = 0 End SelectEnd SubPrivate Sub Command2_Click() 结束命令按钮 EndEnd Sub第四题Private Sub Command1_Click() Dim bzh As Single bzh = Val(Text1.Text) - 105 If Val(Text2.Text) bzh * 1.1 Then Label5.Caption = 偏胖,注意饮食 ElseIf Val(Text2.Text) bzh * 0.9 The

12、n Label5.Caption = 偏瘦,增加营养 Else Label5.Caption = 正常,继续保持 End IfEnd SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 48 To 57, 8 Case Else KeyAscii = 0 End SelectEnd SubPrivate Sub Text2_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 48 To 57, 8 Case Else KeyAscii

13、 = 0 End SelectEnd Sub第五题Private Sub Command1_Click() Dim i%, j%, n% Form1.Cls n = Val(Text1.Text) If n = 10 Then MsgBox 输入错误,请重新输入, vbInformation, 提示信息 Text1 = Text1.SetFocus Exit Sub End If For i = 1 To n 外循环控制打印行数 If i = n / 2 Then Print Tab(10 - i); 每行起始打印位置 For j = 1 To 2 * i - 1 内循环控制打印个数 Prin

14、t Trim(Str(i); 打印内容 Next j Print Else k = n - i + 1 Print Tab(10 - k); For j = 1 To 2 * k - 1 Print Trim(Str(i); Next j Print End If Next iEnd SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then 按回车键调用判断命令按钮 Call Command1_Click Exit Sub End If Select Case Chr(KeyAscii) Case 0 To

15、 9, , Chr(8) Case Else KeyAscii = 0 End SelectEnd Sub第六题Option ExplicitPrivate Sub Form_Click() Dim Ip As Double, Temp As Double Dim N As Double, K As Double Ip = 2: Temp = 2: N = 1 Do Ip = Temp K = 2 * N Temp = Temp * (K / (K - 1) * (K / (K + 1) N = N + 1 Loop Until Abs(Temp - 3.141592) = “a” And c

16、h = “z” Then KeyAscii = KeyAscii 32 End If If KeyAscii 32 Then Pre = KeyAsciiEnd Sub第五章上机试题第一题Private Sub Form_Click() Dim a(1 To 7) As Integer, i%, j% For i = 1 To 7 a(i) = i Print a(i); Next i Print For i = 1 To 7 t = a(7) For j = 6 To 1 Step -1 a(j + 1) = a(j) Next j a(1) = t For j = 1 To 7 Print

17、 a(j); Next j Print Next iEnd Sub第二题Option Base 1Option ExplicitDim a(11) As Integer 定义数组Private Sub cmdcreat_Click() 产生的一维数组 Dim i As Integer Picture1.Cls Picture1.Print 产生的一维数组为: Randomize For i = 1 To 10 a(i) = Int(Rnd * 20 + 10) Picture1.Print a(i); Next i Picture1.PrintEnd SubPrivate Sub cmdmax

18、_Click() 求最大元数及所在的位置 Dim max As Integer, p As Integer, i As Integer max = a(1) 假设第一元素就是最大元素 p = 1 For i = 2 To 10 If a(i) max Then max = a(i) p = i End If Next i Picture1.Print Picture1.Print 第 & p; 个元素 & a(p) & 为最大元素End SubPrivate Sub cmdave_Click() 计算平均值 Dim ave As Single, i As Integer For i = 1 T

19、o 10 ave = ave + a(i) Next i ave = ave / 10 Picture1.Print Picture1.Print 产生的随机数平均值为: & aveEnd SubPrivate Sub cmdsort_Click() 使用选择法排序 Dim i%, j%, p%, t% For i = 1 To 9 p = i For j = i + 1 To 10 If a(p) a(j) Then p = j Next j t = a(i): a(i) = a(p): a(p) = t Next i Picture1.Print Picture1.Print 排序后的一维

20、数组为: For i = 1 To 10 Picture1.Print a(i); Next i Picture1.PrintEnd SubPrivate Sub cmdinsert_Click() 数据插入 Dim x%, p%, i% x = Val(InputBox(输入要插入的数据:) p = 1 Do While x a(p) And p a(j) Then p = j Next j t = a(i): a(i) = a(p): a(p) = t Next i For I = 1 To n Text3.Text = Text3.Text & a(i) & Chr(13) + Chr(10) Next iEnd Sub第六章上机试题第一题 Option Base 1Private Sub InputData(b() As Integer) 给数组输入数据 Dim i%, n%, m% n = LBound(b) m = UBound(b) For i = n To m b(i) = Val(InputBox(Enter & A( & i & )=?) Print b(i); Next i PrintEnd Sub求数组平均值函数过程Private Function Avenum(b() As Integer) As Single Dim s!, i%, n%

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

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