( 21 ) 在窗体上画一个名称为List1 的列表框,一个名称为 Label1 的标签,列表框中显示若干城市的名称 。 当单击列表框中的某个城市名时 , 该城市名从列表框中消失 , 并在标签中显示出来 。 下列能正确实现上述操作的程序是A ) Private Sub List1_Click()Label1.Caption = List1.ListIndexList1.RemoveItem List1.TextEnd SubB ) Private Sub List1_Click()Label1. Name

题目

( 21 ) 在窗体上画一个名称为List1 的列表框,一个名称为 Label1 的标签,列表框中显示若干城市的名称 。 当单击列表框中的某个城市名时 , 该城市名从列表框中消失 , 并在标签中显示出来 。 下列能正确实现上述操作的程序是

A ) Private Sub List1_Click()

Label1.Caption = List1.ListIndex

List1.RemoveItem List1.Text

End Sub

B ) Private Sub List1_Click()

Label1. Name = List1. ListIndex

List1.RemoveItem List1.Text

End Sub

C ) Private Sub List1_Click()

Label1.Caption = List1.Text

List1.RemoveItem List1.ListIndex

End Sub

D ) Private Sub List1_Click()

Label1.Name = List1.Text

List1.RemoveItem List1.ListIndex

End Sub


相似考题
参考答案和解析
正确答案:C
更多“( 21 ) 在窗体上画一个名称为List1 的列表框,一个名称为 Label1 的标签,列表框中显示若干城市的 ”相关问题
  • 第1题:

    在窗体上画一个名称为List1的列表框,一个名称为Label1的标签,列表框中显示若干城市的名称。当单击列表框中的某个城市名时,该城市名从列表框中消失,并在标签中显示出来。下列能正确实现上述操作的程序是______。

    A.Private Sub List1_Click() Label1.Caption=List1.ListIndex List1.RemoveItem List1.Text End Sub

    B.Private Sub List1_Click() Label1.Name=List1.ListIndex List1.RemoveItem List1.Text End Sub

    C.Private Sub List1_Click() Label1.Cavtion=List1.Text List1.RemoveItem List1.ListIndex End Sub

    D.Private Sub List1_Click() Label1.Name=List1.Text List1.RemoveItem List1.ListIndex End Sub


    正确答案:C
    解析:List控件中ListIndex属性表示当前选中项目的索引,Text属性表示当前选中项目的内容,RemoveItern方法表示删除列表项;Label控件的Name属性表示控件的名称,Caption属性表示Label控件显示的内容。

  • 第2题:

    在窗体上画一个名称为List1的列表框,一个名称为Label1的标签。列表框中显示若干城市的名称。当单击列表框中的某个城市名时,在标签中显示选中城市的名称。下列能正确实现上述功能的程序是

    A.Private Sub List1 Click() Label1.Caption=List1.List- Index End Sub

    B.Private Sub List1_Click() Label1.Name=List1. ListIn- dex End Sub

    C.Private Sub List1 Click() Label1.Name=List1.Text End Sub

    D.Private Sub List1_Click() Label1.Caption=List1.Text End Sub


    正确答案:D
    解析:要实现在标签上显示选中城市的名称,很容易想到需使用标签的Caption属性。标签的Caption属性我们前面已经介绍过。怎样获取选中城市的名称要结合列表List的属性来考虑。其中Text属性表示最后选中列表项的内容。故正确语句应为Label1.Caption=List1.Text。选项D正确。

  • 第3题:

    在窗体上画一个名称为List1的列表框,一个名称为Labe11的标签,列表框中显示若干城市的名称。当单击列表框中的某个城市名时,该城市名从列表框中消失,并在标签中显示出来。下列能正确实现上述操作的程序是( )。

    A.

    B.

    C.

    D.


    正确答案:C

  • 第4题:

    在窗体上画一个名称为Listl的列表框,一个名称为Label1的标签。列表框中显示若干城市的名称。当单击列表框中的某个城市名时,在标签中显示选中城市的名称。 下列能正确实现上述功能的程序是

    A.Private Sub List1_Click() Label1.Caption=List1.ListIndex End Sub

    B.Private Sub List1-Click() Label1.Name=List1.ListIndex End Sub

    C.Private Sub List1_Click() Label1.Name=List1.Text End Sub

    D.Private Sub List1_Click() Label1.Caption=List1.Text End Sub


    正确答案:D
    解析:本题考查列表框的属性。列表框属性是历年考试热点之一。本题主要区分Listlndex与Text属性。ListIndex指被选中项的下标,而Text表示被选中项的内容。故List1.ListIndex表示被选中的项本身,而List1.Text表示被选中项的内容,故该题选D。同时本题再次涉及Name与 Caption的区别。

  • 第5题:

    在窗体上画一个名称List1的列表框,一个名称为Label1的标签。列表框中显示若干城市的名称。当单

    A.Private Sub list1_Click() Label1. Caption= List1. ListIndex End Sub

    B.Private Sub Listl_Click() Label1. Name= List1. ListIndex End Sub

    C.Private Sub List1_Click() Label1. Name== List1. Text End Sub

    D.Private Sub List1_Click() Label1. Caption: List1. Text End Sub


    正确答案:D
    解析:标签的Caption属性用来显示标签的文本内容,因此选项B和C错误。列表框的ListIndex属性指定已选中的列表框项的位置,不选任何项,其值为-1,第一项从。开始;列表框的Text属性指定选中的列表框项的文本内容,因此只有选项D正确。