|
-
Oct 17th, 2001, 05:30 PM
#1
Thread Starter
Member
What am I doing wrong here?
<code>
Const LB_GETCURSEL = &H188
Const LB_GETSELITEMS = &H191
Const LB_SETITEMDATA = &H19A
Const LB_ADDSTRING = &H180
Const LB_GETTEXT = &H189
Const LBN_DBLCLK = 2
Private Function GetDataFromListbox() As String
Dim Index As Long
Dim lstSize As Long
Dim lstText As String
Index = SendMessage(lngHwndlstData, LB_GETCURSEL, 0&, ByVal 0&)
lstSize = SendMessage(lngHwndlstData, LB_GETTEXTLEN, Index, ByVal 0&)
lstText = Space(lstSize)
Call SendMessage(lngHwndlstData, LB_GETTEXT, Index, ByVal lstText)
GetDataFromListbox = lstText
End Function
</code>
And lngHwndlstData is the handle to my listbox. I'm just trying to get the data from the listbox.
-
Oct 18th, 2001, 05:28 AM
#2
You need to check for LB_ERR returns
Code:
Const LB_ERR = (-1)
When you get values back from these callls. The LB could be empty for instance.
Here's an example of calling SendMessage to get text from a listbox (the example is not checking for LB_ERR, either)
http://www.vbapi.com/ref/l/lb_gettext.html
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
|