在窗体上画一个名称为Drive1的驱动器列表框,一个名称为Dir1的目录列表框,一个名称为File1的文件列表框,两个名称分虽为Lahel1、Label2,标题分别为空白和 "共有文件"的标签。编写程序,使得驱动器列表框与目录列表框、目录列表框与文件列表框同步变化,并且在标签Label1中显示当前文件夹中文件的数量。如图所示。能够正确实现上述功能的程序是
A.Private Sub Dir1_Change( ) FilePath=Dir1.Path End Sub Private Sub Dive1_Change( ) Dir1.Path=Drive1.Drive Label1,Caption=File1 ListCount End Sub
B.Private Sub Dir1_Change( ) FilPath=Dtr1.Path End Sub privage Sub Dive1_Change( ) Dir1.path=Drive1.Drive Lahel1.Caption=File1.List End Sub
C.Private Sub Dir1_Change( ) File1. Path = DirPath Label1.Caption=File1, ListCount End Sub Private Sub Drive1_Change( ) Dir1.Path = Drive1. Drive Label1.Captiol1 = File1.ListCount End Sub(
D.Private Sub Dir1_Change( ) File Path = DirPath Label1.Caption = File1.ListCount End Sub Private Sub Dive1_Change( ) Dir1.Path = Drive1.Drive Label1.Caption = File1.List End Sub
参考答案:C
解析:解析:驱动器列表框、目录列表框、文件列表框之间可以通过Path属性相互联系。如在驱动器列表框的Change事件占加入代码Dirl.Path=Drivel.Drive,在目录列表框的Change事件中加入代码Filel.Path=Dirl.Path。要在标签中显示当前文件夹中的文件数量应该在目录列表框的Change事件中加入代码Labell.Caption=Filel.ListCount,其中显示当前文件夹中的文件数量应该使用文件列表框的ListCount属性,而不是List属性。