|
-
Jan 13th, 2006, 04:31 PM
#1
Thread Starter
New Member
Listbox Search. API vs. Vb.net Built-in
I have found two ways to search a listbox for a string.
First way is to use api:
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
'Searchs a listbox for a matching string. Returns the listindex of the matching item.
Function ListboxFindString(strSearchString As String, lHwndListbox As Long) As Long
Const LB_FINDSTRING = &H18F
ListboxFindString = SendMessage(lHwndListbox , LB_FINDSTRING, -1, ByVal strSearchString)
End Function
and the second, the vb.net built-in function:
VB Code:
Dim i As Integer = ListBox1.FindString("String To Find")
Even tho the second one is much smaller, which one from those is the fastest? Anyone Know?
-
Jan 13th, 2006, 05:00 PM
#2
Re: Listbox Search. API vs. Vb.net Built-in
I'm sure that ListBox.FindString is calling the API underneath.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jan 13th, 2006, 09:03 PM
#3
Re: Listbox Search. API vs. Vb.net Built-in
What do you think the .NET Framework is? It's a layer between you and Windows that calls all the Windows APIs for you to save you having to write ugly, complex code. As a result, .NET code will execute more slowly, but it will generally not be significant enough to notice in the real world. If you're going to start calling API functions in place of .NET properties and methods then you may as well not be using .NET at all. If speed is of the essence then .NET is probably not the platform to be using.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|