问题 单项选择题

窗体上有一个名称为Text1的文本框和—个名称为Command1的命令按钮。要求程序运行时,单击命令按钮,就可把文本框中的内容写到文件out.txt中,每次写入的内容附加到原有内容之后。下面能够正确实现上述功能的程序是______。

A.Private Sub Command1_Click()Open "outxt" For Input As#1Print #1,Text1.TextClose #1 End Sub

B.Private Sub Command1_Click()Open "outxt" For Output AS #1Print #1,Text1.TextClose #1 End Sub

C.Private Sub Command1_Click()Open "outxt" For Append As #1Print #1,Text1.TextClose #1 End Sub

D.Private Sub Command1_Click()Open "outxt" For Random As #1Print #1,Text1.TextClose #1 End Sub

答案

参考答案:C

解析:[评析] 打开文件的命令是Open,其常用形式为Open“文件名”For 模式 As[#]文件号 [Len=记录长度],模式为以下形式之一:Output:打开一个文件,将对该文件进行写操作。 Inout:打开一个文件,将对该文件进行读操作。 Append:打开一个文件,将在该文件末尾追加记录。如果未指定方式,则以Random访问方式打开文件。

单项选择题
单项选择题