VB6.0中LISTBOX的查找问题
在Text中的字符串属于不属于listbox的因素.这是自定义Function:PublicFunctiontawa(ByValtextAsString,ByVallis...
在Text中的字符串属于不属于listbox的因素. 这是自定义Function:
Public Function tawa(ByVal text As String, ByVal list As ListBox) As Boolean
Dim kg As Boolean
For i = 0 To list.ListCount - 1
list.ListIndex = i
If text = list.text Then
kg = True
Exit For
Else
kg = False
End If
Next i
tawa = kg
End Function
如果属于的话返回True , 不属于的话返回Flase 展开
Public Function tawa(ByVal text As String, ByVal list As ListBox) As Boolean
Dim kg As Boolean
For i = 0 To list.ListCount - 1
list.ListIndex = i
If text = list.text Then
kg = True
Exit For
Else
kg = False
End If
Next i
tawa = kg
End Function
如果属于的话返回True , 不属于的话返回Flase 展开
3个回答
展开全部
你这个也没问题啊,哪里报错了。。不过还可以简化一下而已
Public Function tawa(ByVal text As String, ByVal list As ListBox) As Boolean
tawa = False
For i = 0 To list.ListCount - 1
If text = list.list(i) Then
tawa = True
Exit For
End If
Next i
End Function
Public Function tawa(ByVal text As String, ByVal list As ListBox) As Boolean
tawa = False
For i = 0 To list.ListCount - 1
If text = list.list(i) Then
tawa = True
Exit For
End If
Next i
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
If text = list.text Then 这句有问题,list.text是指列表中被选中的文本,应该改为:
if text=list.list(i) then
list.ListIndex = i 这句不起作用
if text=list.list(i) then
list.ListIndex = i 这句不起作用
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Public Function tawa(ByVal text As String, ByVal list As ListBox) As Boolean
For i = 0 To list.ListCount - 1
list.ListIndex = i
If text = list.text Then tawa = True: Exit For
Next i
End Function
For i = 0 To list.ListCount - 1
list.ListIndex = i
If text = list.text Then tawa = True: Exit For
Next i
End Function
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询