?
Solved

highlighting information in a listbox

Posted on 2005-03-22
3
Medium Priority
?
200 Views
Last Modified: 2010-05-02
is there a way that i can highlight my old values in a list box

i am loading names from an ini file to an ADODB.Recordset

if my value in my adodb.recordset is set to true then highlight the name in the listbox
this is what I have so far



Set companyData = CC.getCompanyListingFromIniFile(companyData, g_sINIfile)

companyData.MoveFirst

While Not companyData.EOF

     If companyData.Fields("databaseSelected").Value = True Then

         strFind = companyData.Fields("name").Value
          lngindex = SendMessageString(companyList.hwnd, _
                         LB_FINDSTRINGEXACT, _
                         -1, _
                         strFind)
   
     If lngindex > -1 Then
        'I AM TRYING TO HIGHLIGHT EVERY LIST INDEX WITH THE CORRECT NAME BUT NOTHING IS HIGHLIGHTED.
         MYLISTBOX IS SET TO MULTISELECT = 2
        companyList.ListIndex= lngIndex
     
        MsgBox "Item already in List"
    End If

End If

companyData.MoveNext
Wend


0
Comment
Question by:genesisproject
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Expert Comment

by:Fox_What
ID: 13607667
companyList.selected(lngIndex) = True
0
 
LVL 9

Accepted Solution

by:
dmang earned 2000 total points
ID: 13614876
Looks like you need to iterate through the list..    

 strFind = companyData.Fields("name").Value
With companyList
       For i = 0 To .ListCount - 1
        If strFind = "" Then
           .ListIndex = -1
        Else
           lngpos = SendMessage(.hwnd, _
                                LB_FINDSTRINGEXACT, _
                                i - 1, _
                                ByVal  strFind)
           If lngpos >= 0 Then
              .Selected(lngpos) = True
           End If
        End If
        Next i
    End With
0
 

Expert Comment

by:Fox_What
ID: 13656471
You only had to change the one line.

No need to iterate through the list, the
return from the sendmessage gave the index
of the item you were looking for. And since
you are iterating through the recordset,
everything would be highlighted.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question