设在工程中有一个标准模块,并定义了如下类型: Type Stutype ino As Integer stmame As String*20 strsex As String*2 smarkAs Single End Type 在窗体上画一个名为Comma

admin2020-06-30  30

问题 设在工程中有一个标准模块,并定义了如下类型:
Type Stutype
ino As Integer
stmame As String*20
strsex As String*2
smarkAs Single
End Type
在窗体上画一个名为Commandl的命令按钮,要求当执行事件过程Commandl Click时,在C盘根目录下的随机文件Student.dat中写入一条记录。下列能够完成该操作的是(     )。

选项 A、Sub Commandl_Click(     )
Dim student As Studtype
Dim record_no As Integer
record_no=1
With student
.ino=12:.stmame=“smitll”:
.strsex=“男”:.smark=89
End With
Open”c:\Student.dat”ForInputAs#1 Len=
Len(Student)
Put#1,record_no,Student
Close#1
EndSub
B、Sub Commandl_click(     )
Dim Student As Stutype
Dim Record_no As Integer
Record_no=1
With Student
.ino=12:.stmame=“smith”
.sffsex=“男”:.smark=89
End With
Open”c:\student.dat”For Random As#1 Len
=Len(Student)
Put#1,Record_no,Student
Close#1
EndSub
C、Private Sub Commandl_Click(     )
Dim StudentAs Stutype
Dim Record_no As Integer
Record_no=1
With Student
.ino=12:.strname=“smith”
.strsex=“男”:.smark=89
EndWith
Open”c:\student.dat”For Random As 1 Len=
Len(Student)
Write#1,Record_no,Student
Close#1
End Sub
D、Sub Commandl_Click(     )
Dim StudentAs Stutype
Dim Record_no As Integer
Record_no=1
With Student
.ino=12:.stmame=“smith”
.strsex=“男”:.smark=89
End With
Open”c:\student.dat”For Output As #1 Len=
Len(Student)
Put#1,Record_no,Student
Close#1
End Sub

答案B

解析 考查文件操作。题目中要求以随机的方式(Random)打开一个文件,打开文件的方法格式为:Open FileName For Random As#文件号[Len=记录长度],然后以Put方法写入一条记录,方法的格式为:Put[#]文件号,[记录号],变量名。
转载请注明原文地址:https://kaotiyun.com/show/RmHp777K
0

相关试题推荐
最新回复(0)