CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Listbox text selection

    Hello,
    I need to highlight text in the listbox based on what was typed in the combobox, but the

    List1.ListIndex = SendMessage(List1.hwnd, LB_SELECTSTRING, -1, Combo1.Text)



    Doesn't work for some reason. What am I doing wrong? Thank You


  2. #2
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090

    Re: Listbox text selection

    Change your declaration of SendMessage toublic Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" _
    (byval hWnd as Long, _
    byval wMsg as Long, _
    byval wParam as Long, _
    lParam as Any) as Long





  3. #3
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Listbox text selection

    yeah, that's exactly what I have and still no idea why it won't work. Thanks for the help.


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Listbox text selection

    I tried your code. It works if you change the line to the following

    List1.ListIndex = SendMessage(List1.hWnd, LB_SELECTSTRING, -1, ByVal CStr(Combo1.Text))


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Listbox text selection

    the fourth parameter (the string to search for) also has to be passed ByVal...


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

Featured