第十一章
一、选择题:
1—3: DDA
二、填空题
6 2.AB A
三、编程题
1.Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x
As Single, Y As Single)
Text1 = x: Text2 = Y
End Sub
2.
Dim startX, StartY As Integer ‘在通用中申明
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As
Single, Y As Single)
If Button = 2 Then
startX = x: StartY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As
Single, Y As Single)
If Button = 1 Then
PSet (x, Y), RGB(0, 0, 0)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As
Single, Y As Single)
If Button = 2 Then
Dim r%, c%
Dim EndX, EndY As Integer
EndX = x: EndY = Y
c = RGB(0, 0, 0)
r = Sqr((EndX - startX) ^ 2 + (EndY - StartY) ^ 2)
Form1.Circle (startX, StartY), r, c
End If
End Sub
第十二章
一、选择题:
1—8: BBABBCCA
9.I H F C L G E B A J K D
二、填空题
1.Drive 2.Path Print Dir1.Path
3.Path 4.Hidden system
5.顺序文件 随机文件 二进制文件
6.FreeFile
7.Close #1
8.Open “c:\samples\readme.txt” For Output AS #3
9.Open “c:\autoexec.bat” For Intput AS #4
10.Open “c:\samples\xscj.dat” For Random AS #3 Len=54
11.Open “smtext1.txt” For Binary AS #1
12.For Input Eof(1)
13.KeyAscii END(或者End end eNd enD) Text1.text
三、编程题
1.‘在标准模块中定义
Type stu
ID As String * 12
name As String * 8
z1 As String * 12
z2 As String * 12
sex As String * 2
jc As Boolean
scool As String * 20
sx As Integer
yw As Integer
yy As Integer
wl As Integer
zf As Integer
End Type
Dim p As stu ‘在通用中定义
Private Sub CmdAppend_Click()
p.ID = Text1
p.name = Text2
p.z1 = Text3
p.z2 = Text4
p.scool = Text5
If Option1.Value = True Then p.sex = "男"
If Option2.Value = True Then p.sex = "女"
If Check1.Value = 1 Then p.jc = True Else p.jc = False
p.sx = Val(Text6) : p.yw = Val(Text7)
p.yy = Val(Text8) : p.wl = Val(Text9)
p.zf = Val(Text10)
Put #1, , p
End Sub
Private Sub CmdDisplay_Click()
Get #1, Val(txtRecord_No), p
Text1 = p.ID : Text2 = p.name
Text3 = p.z1 : Text4 = p.z2
Text5 = p.scool
If p.sex = "男" Then Option1.Value = True Else Option2.Value = True
If p.jc = True Then Check1.Value = 1 Else Check1.Value = 0
Text6 = p.sx : Text7 = p.yw
Text8 = p.yy : Text9 = p.wl
Text10 = p.zf
End Sub
Private Sub Command3_Click()
Text1 = "" : Text2 = ""
Text3 = "" : Text4 = ""
Text5 = "" : Text6 = ""
Text7 = "" : Text8 = ""
Text9 = "" : Text10 = ""
End Sub
Private Sub Form_Load()
Open App.Path & "\stu.dat" For Random As #1 Len = Len(p)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
End Sub
Private Sub Text10_GotFocus()
Text10 = Val(Text6) + Val(Text7) + Val(Text8) + Val(Text9)
End Sub
2.3.4.
Private Type books
id As String * 10
name As String * 8
sex As String * 2
math As Integer
eng As Integer
ele As Integer
End Type
‘成绩输入
Private Sub Command1_Click()
Dim b As books
Open "c:\stu.dat" For Append As #1
b.id = InputBox("请输入学号")
b.name = InputBox("请输入姓名")
b.sex = InputBox("请输入性别")
b.math = InputBox("请输入数学成绩")
b.eng = InputBox("请输入英语成绩")
b.ele = InputBox("请输入电子成绩")
Write #1, b.id, b.name, b.sex, b.math, b.eng, b.ele
Close #1
End Sub
‘不及格人员输出
Private Sub Command2_Click()
Dim a, b, c
Open "c:\stuo.dat" For Input As #1
While Not EOF(1)
Input #1, a, b, c
If c = "数学" Then List1.AddItem b
If c = "英语" Then List2.AddItem b
If c = "电子" Then List3.AddItem b
Wend
Close #1
End Sub
‘将不及格人选出存入stuo.dat
Private Sub Command3_Click()
Dim a, b, c, d, e, f
Dim k%
Open "c:\stu.dat" For Input As #1
Open "c:\stuo.dat" For Output As #2
While Not EOF(1)
Input #1, a, b, c, d, e, f
If d < 60 Then Write #2, a, b, "数学"
If e < 60 Then Write #2, a, b, "英语"
If f < 60 Then Write #2, a, b, "电子"
Wend
Close #1
Close #2
End Sub