问题 单项选择题

在窗体上画一个名称为Drivel的驱动器列表框,一个名称为Dirl的目录列表框,一个名称为Filel的文件列表框,两个名称分别为Label1、Label2、标题分别为空白和“共有文件”的标签。编写程序,使得驱动器列表框与目录列表框、目录列表框与文件列表框同步变化,并且在标签Labell中显示当前文件夹中文件的数量。如图所示。

能够正确实现上述功能的程序是

A.PriVate Sub Dir1_Change() FilePath=Dir1.Path End Sub Private Sub Dirvel_Change() Dir1.Path=DriveDriveLabelCaption=FileListCount End Sub

B.Private Sub Dir1_Change() FilePath=Dir1.Path End Sub Private Sub Drivel_Change() DirPath=DriveDrive LabelCaption=FileList End Sub

C.Private Sub Dir1_Change() FilePath=Dir1.PathLabelCaption=File1.ListCount End Sub Private Sub Drivel_Change() Dir1.Path=DriveDriveLabelCaption=Fil1.ListCount End Sub

D.Private Sub Dir1_Change() File1.Path=Dir1.PathLabelCaption=FileList End Sub Private Sub Drivel_Change() Dir1.Path=DriveDriveLabelCaption=FileList End Sub

答案

参考答案:C

解析: List属性用来列出表项的内容,可以加下标用“()”括起来配合使用。根据题意,应选择文件列表框的ListCount属性,该属性用于返回文件的数量值。故B、D项错误。A项缺少“Label1.Caption=Filel.ListCount”这一语句,从而使得在仅触动Dirl的Change事件时,Labell没有反应。

单项选择题 A1型题
选择题