get text from listbox



Trying to get the text of items in a listbox of an external application.
This code will get me some data, but it is in non-readable form like this:
¸îA`

Private Declare Function SendMessageLong Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long


Private Declare Function SendMessageStr Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String) As Long


Private Const LB_GETTEXT = &H189
Private Const LB_GETCOUNT = &H18B

Sub test()

   Dim r As Long
   Dim i As Long
   Dim maxItems As Long
   Dim listStr As String
   Dim lLBhwnd As Long

   lLBhwnd = 7275646

   maxItems = SendMessageLong(lLBhwnd, LB_GETCOUNT, 0, 0)

   For i = 0 To maxItems - 1
       listStr = Space$(64)
       r = SendMessageStr(lLBhwnd, LB_GETTEXT, i, listStr)
       If r > 0 Then
           MsgBox Left$(listStr, r)
       End If
   Next

End Sub


Would there be a way to get the readable data?


RBS



.



Relevant Pages

  • Re: get text from listbox
    ... ByVal lParam As String) As Long ... Dim r As Long ... Dim listStr As String ...
    (microsoft.public.vb.winapi)
  • Re: get text from listbox
    ... ByVal lParam As String) As Long ... Dim r As Long ... Dim listStr As String ...
    (microsoft.public.vb.winapi)
  • Re: get text from listbox
    ... ByVal lParam As String) As Long ... Dim r As Long ... Dim listStr As String ... Dim lLBhwnd As Long ...
    (microsoft.public.vb.winapi)
  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)

Loading