Public Function judge(t As String) As Boolean
Dim i As Integer
judge = False
For i = 0 To List1.ListCount
If t = Mid(List1.List(i), 1) Then
Text1.Text = ""
Text1.SetFocus
judge = True
Exit For
End If
judge = False
Next i
End Function
Dim i As Integer
judge = False
For i = 0 To List1.ListCount
If t = Mid(List1.List(i), 1) Then
Text1.Text = ""
Text1.SetFocus
judge = True
Exit For
End If
judge = False
Next i
End Function
Dim i As Integer
For i = 1 To List1.ListCount
If t = Mid(List1.List(i), 7, 1) Then
Text1.Text = ""
Text1.SetFocus
judge = True
Exit Function
End If
Next i
judge = False
End Function
Option ExplicitPrivate Declare Function SendMessagebyString Lib _
"user32" Alias "SendMessageA" (ByVal hWND As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String) As LongPrivate Const LB_FINDSTRINGEXACT = &H1A2
Private Const CB_FINDSTRINGEXACT = &H158Public Function FindStringinListControl(ListControl As Object, _
ByVal SearchText As String) As Long'Input:
'ListControl: List or ComboBox Object
'SearchText: String to Search For'Returns: ListIndex of Item if found
'or -1 if not found
Dim lHwnd As Long
Dim lMsg As LongOn Error Resume Next
lHwnd = ListControl.hWNDIf TypeOf ListControl Is ListBox Then
lMsg = LB_FINDSTRINGEXACT
ElseIf TypeOf ListControl Is ComboBox Then
lMsg = CB_FINDSTRINGEXACT
Else
FindStringinListControl = -1
Exit Function
End IfFindStringinListControl = SendMessagebyString _
(lHwnd, lMsg, -1, SearchText)End Function
Dim i As Integer
For i = 1 To List1.ListCount
judge= (t = Mid(List1.List(i), 7, 1)
if judge then
Text1.Text = ""
Text1.SetFocus
Exit Function
end if
Next i
End Function
Listbox,Combobox有一些功能在VB中没有体现,比如查找,直接用消息。