在E盘当前目录文件夹下建立一个名为“Student.txt”的随机文件,要求用InputBox函数输入5个学生的姓名(StuName)、年级(StuGrade)和年龄(StuAge)。在程序中有以下记录类型和窗体的事件过程,请选择正确的语句完成程序(

admin2010-03-30  27

问题 在E盘当前目录文件夹下建立一个名为“Student.txt”的随机文件,要求用InputBox函数输入5个学生的姓名(StuName)、年级(StuGrade)和年龄(StuAge)。在程序中有以下记录类型和窗体的事件过程,请选择正确的语句完成程序(    )。    Private Type student       StuName As String*10       StuGrade As String*10    StuAge As Integer    End Type    Private Sub Form_Click()    Dim s As student       Open "c:\student.txt" For Random As #1 Len=Len(s)       For i=1 To 1         s.StuName=InputBox("请输入姓名")         s.StuGrade=InputBox("请输入年级号")         s.StuAge=Val(InputBox("请输入年龄"))       Next i       Close #1    End Sub

选项 A、Print #1,s
B、Print #1,i
C、Put #1,,s
D、Put #1,,i

答案4

解析 本题考查随机文件的读写,在For循环中,向随机文件中写入5个学生的信息,所以应该使用写操作语句,在随机文件中,写操作用Put语句,其格式为:Put#文件号,[记录号],变量。
转载请注明原文地址:https://kaotiyun.com/show/X6mp777K
0

最新回复(0)