在这里,我有一个在 vb.net 中实现 matchwithlist 的示例,但是还有其他方法可以做到这一点。在 vb 中,代码很简单combo1.matchwithlist
得到的来自http://support.microsoft.com/kb/266265/en-us
Private Sub Combo1_Change()
Dim listcount As Integer
Dim textlen As Integer
Dim matchexists As Boolean
textlen = Len(Combo1.Text)
For listcount = 0 To Combo1.listcount - 1
If UCase(Mid(Combo1.List(listcount), 1, textlen)) = UCase(Combo1.Text) Then
matchexists = True
Exit For
End If
Next
If Not matchexists Then
MsgBox "Value not present in the list... Kindly enter a valid value.."
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "Sam"
Combo1.AddItem "Paul"
Combo1.AddItem "Peter"
Combo1.Text = ""
End Sub