Private Sub Command1_Click()
Dim i As Integer
Dim isFind As Boolean
isFind = False
For i = 0 To ListBox1.ListCount - 1
If ListBox1.List(i) = TextBox1.Text Then
MsgBox "A" '有找到
isFind = True
Exit For
End If
Next
'没有找到
If Not isFind Then
MsgBox "B"
End If
End Sub
追问你好,非常感谢!因为我用的是 Microsoft Visule Studio
然后它显示这样,不知道可以怎么解决呢?
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/8b82b9014a90f603e447f6383612b31bb151edde?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
追答你用的是vb.net
你把ListCount改成Items.Count
把List(i)改成Items.Item(i)
还有你程序中lstCustomerHistory.text是你的textbox吗?
追问lstCustomerHistory是listbox,那里打错了。谢谢提醒~