在窗体上画一个名称为Combol的组合框,然后画两个名称分别为Label1、Label2,标题分别为“城市名称”
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then
For i=0 To Combo1.ListCount-1
If Combo1.Text=【 】Then
Label2.Caption="输入项已在组合框中。"
Exit Sub
End If
Next i
Label2.Caption="已成功添加新输入项。"
Combo1.【 】Combo1.Text
End If
End Sub
![](https://lstatic.shangxueba.com/sxbcn/h5/images/tips_org.png)