假定在工程文件中有一个标准模块,其中定义了如下记录类型: Type Books Name As String*10 TelNum As String*20 End Type 要求当执行事件过程Command1_

admin2010-09-11  21

问题 假定在工程文件中有一个标准模块,其中定义了如下记录类型:    Type Books        Name As String*10        TelNum As String*20    End Type    要求当执行事件过程Command1_Click时,在顺序文件Person. txt中写入一条记录。下列能够完成该操作的事件过程是______。

选项 A、Private Sub Command1_Click()              Dim B As Books              Open"c:\Person. txt" For Output As #1              B. Name=InputBox("输入姓名")              B. TelNum=InputBox("输入电话号码")              Write #1, B. Name, B. TelNum              Close #1          End Sub
B、Private Sub Command1_Click()              Dim B As Books              Open"c:\Person txt" For Output As #1              B. Name=InputBox("输入姓名")              B. TelNum=InputBox("输入电话导码")              Print #1, B. Name, B. TelNum              Close #1          End Sub
C、Private Sub Command1_Click()              Dim B As Books              Open"c:\Person. txt" For Output As #1              Name=InputBox("输入姓名")              TelNum=InputBox("输入电话号码")              Print #1, B              Close #1          End Sub
D、Private Sub Command1_Click()              Dim B As Books              Open "c:\Person txt" For Output As #1              Name=InputBox("输入姓名")              TelNum=InputBox("输入电话号码")              Print #1, B Name, B. TelNum              Close #1          End Sub

答案A

解析 要向顺序文件中写入记录必须用For Output参数打开文件,然后用Print#或Write#语句将内容写入文件,因此选项B和选项D不正确;又因为自定义数据类型变量的引用要用“变量名. 变量元素名”,所以选项C不正确。故本题的正确答案只有选项A。
转载请注明原文地址:https://kaotiyun.com/show/eump777K
0

最新回复(0)