Results 1 to 2 of 2

Thread: What am I doing wrong here?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    32

    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.

  2. #2
    jim mcnamara
    Guest
    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
  •  



Click Here to Expand Forum to Full Width