填空题 VB
题号 #483732

在窗体上画一个名称为Combo1的组合框,然后画两个名称分别为Label1、Label2,标题分别为“城市名称”和空白的标签。程序运行后,在组合框中输入一个新项目并按回车键,如果输入的项目在组合框的列表中不存在,则自动将其添加到组合框的列表中,并在Label2中给出提示“已成功添加新输入项。”,如图所示。如果输入的项目已存在,则在Label2中给出提出“输入项已在组合框中。”请填空。
Private Sub Combol_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then
For i=0 To Combol.TistCount-1
If Combol.Text=【1】Then
Label2.Caption=“输入项已在组合框中。”
Exit Sub
End If
Next i
Label2.Caption= “已成功添加新输入项。”
Combol. 【2】Combol.Text
End If
Fnd Sub

进入在线模考

参考答案

暂无

答案解析

【1】 Combol.List(i)【2】Addltem【分析】组合框中的表项用其List属性描述,它是保存了组合框中所有值的数组,其下标是从0开始的。要表示组合框中的下标为i的表项,其表达式为Comb01.List(i),所以,【I】处应填Combol.List(i)。要向组合框中添加新的表项,应使用组合框的Addltem方法,所以,【2】处应填Addltem。

你可能感兴趣的试题

A.Private Sub Text1_lick()
Label 1.Caption=Text 1.Text
End Sub
B.Private Sub Text1_hange()
Label1.Caption=Text1.Text
End Sub
C.Private Sub Labe1 l_hange()
Label 1.Caption=Text 1.Text
End Sub
D.Private Sub Labl l_Click()
Label 1.Caption=Text1.Text
End Sub
A.Private Sub List1_Click()
Label1.Caption=List1.ListIndex
List 1.RemoveItem List 1.Text
End Sub
B.Private Sub List1_Click()
Label1.Name=List1.ListIndex
List1.RemoveItem List1.Text
End Sub
C.Private Sub List1_Click()
Label 1.Caption=List 1.Text
List 1.RemoveItem List 1.ListIndex
End Sub
D.Private Sub List1_Click()
Label1.Name=List1.Text
List1.RemoveItem List1.ListIndex
End Sub
找试题 · 找答案 · 找资料 在线模考