设在工程中有一个标准模块,其中定义了如下记录类型 Type Books Name As String* 10 TelNum As String * 20 End Type 在窗

admin2009-03-15  36

问题 设在工程中有一个标准模块,其中定义了如下记录类型        Type Books             Name As String* 10             TelNum As String * 20       End Type    在窗体上画一个名为 Command1的命令按钮,要求当执行事件过程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
B、Private Sub Command1_Click( )             Dim B As Books             Open "c:\Person.txt, For Input As # 1                      B.Name = lnputBox("输入姓名")                      B.TelNum = InputBox("输入电话号码")                     Print #1, B.Name, B.TelNttm   
C、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             Close #
D、Private Sub Command1_Click( )     Dim B As Books    Open"c:\Person.txt" For Input As #1       Name=InputBox("输入姓名")       TelNum=InputBox("输入电话号码")       Print #1,Name,TelNum     Close #1    End Sub

答案1

解析 A选项正确。
   B选项向文件中输出内容,打开方式应当为For output。
   C选项记录变量不可以对元素整体输入输出。
   D选项记录变量的输入和输出都必须指明到记录元素。格式为:记录变量.元素名。
转载请注明原文地址:https://jikaoti.com/ti/XJq0FFFM
0

最新回复(0)