| 发表于:2007-01-23 11:31:092楼 得分:0 |
这是msdn中的例子,看看吧。 listindex 属性示例 这个例子在 listbox 控件中显示三个演员的名字,在 label 控件中显示被选中的演员所对应的薪金。要尝试这个例子,请将代码粘贴到包含一个 combobox 控件和一个 label 控件的窗体的声明部分,然后按 f5 键并在 combobox 中选择一个名字。 dim player(0 to 2) ' 说明两个数组的大小。 dim salary(0 to 2) private sub form_load () dim i ' 声明变量。 autosize = true player(0) = "miggey mcmoo " ' 在数组中输入数据。 player(1) = "alf hinshaw " player(2) = "woofer dean " salary(0) = "$234,500 " salary(1) = "$158,900 " salary(2) = "$1,030,500 " for i = 0 to 2 ' 在列表中添加名字。 combo1.additem player(i) next i combo1.listindex = 0 ' 显示列表中的第一项。 end sub private sub combo1_click () ' 显示名字所对应的薪金。 label1.caption = salary(combo1.listindex) end sub | | |
|