文档详情

浙江理工大学vb课后练习八答案.doc

发布:2018-03-08约2.8千字共3页下载文档
文本预览下载声明
第四节 教材习题解答 一、判断题 12.× 3.× 4.√ 5.√ 6.× 7.× 8.√ 9.× 10.√ 二、选择题 12.C 3.B 4.D 5.B 6.C 7.B 8.A 三、填空题 12. 不能 3. Write# 4. Close# 四、程序阅读题Private Sub Command1_Click() Dim i As Integer, j As Integer, a(4, 5) As Single, max As Single Open aaa.txt For Input As #1 For i = 1 To 4 For j = 1 To 4: Input #1, a(i, j): Next j Next i Close #1 Open bbb.txt For Output As #1 For i = 1 To 4 max = a(i, 1) For j = 2 To 4 If Abs(a(i, j)) Abs(max) Then max = a(i, j) Next j For j = 1 To 4 a(i, j) = a(i, j) / max If j 4 Then Write #1, a(i, j), Else Write #1, a(i, j) Next j Next i Close #1 End Sub 题2.程序代码如下 Private Sub Command1_Click() Dim xm As String,xh As String,c1 As Byte,k As Byte,c2 As Byte,c3 As Byte Open score.txt For Input As #1 Open bad.txt For Output As #2: Open pass.txt For Output As #3 Do While Not EOF(1) Input #1, xm, xh, c1, c2, c3 k = 0: If c1 = 60 Then k = k + 1 If c2 60 Then k = k + 1 If c3 60 Then k = k + 1 If k 2 Then Write #3,xm,xh,c1,c2,c3 Else Write #2,xm,xh,c1,c2,c3 Loop Close End Sub 题3.程序代码如下 Private Sub Command1_Click() Dim mc As String, lb As String, pp As String, sl As Integer Open kucun.txt For Input As #1 Open temp.txt For Output As #2 Do While Not EOF(1) Input #1, mc, lb, pp, sl If sl 0 Then Write #2, mc, lb, pp, sl Loop Close Kill kucun.txt: Name temp.txt As kucun.txt End Sub 题4.程序代码如下 Dim x1 As Single, y1 As Single, x2 As Single, y2 As Single, k As Byte Private Sub Command1_Click() On Error GoTo pp Open record.txt For Input As #1 Do While Not EOF(1) Input #1, k, x1, y1, x2, y2 If k=1 Then P2.Line (x1,y1)-(x2,y2) Else P2.Line (x1,y1)-(x2,y2),,B Loop Close #1 Exit Sub pp: MsgBox 文件为空,请先在P1中绘制图形 End Sub Private Sub P1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) x1 = X: y1 = Y End Sub Private Sub P1_MouseUp(Button As Integer, Shift As
显示全部
相似文档