Highlight Items in a Listbox using a '>=' or '<=' button? (1 Viewer)

kapaw

Registered User.
Local time
Today, 09:54
Joined
Mar 30, 2011
Messages
30
I have a listbox that have a list of numbers:
lstDCR:
0.37
0.45
0.56
1.02
2.05
5.67

I'm trying to create a code that will highlight numbers greater than or equal to when a '>=' is clicked(same thing with less than). Is there a command that will do this: lstDCR.Highlight?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,118
greater than or equal to what? It's simple enough to loop the listbox:

Code:
    Dim ctl As Control
    Dim i As Integer

    Set ctl = Me.LisboxName

    For i = 0 To ctl.ListCount - 1
      'test the value, if it meets the criteria:
      ctl.Selected(i) = True
    Next i
 

kapaw

Registered User.
Local time
Today, 09:54
Joined
Mar 30, 2011
Messages
30
Greater thatn or equal to a selected item on the listbox.
Ex: If a user selected 1.02 and click '>=', 0.37 to 1.02 will be highlighted.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,118
Just get that value before the loop and then test each value against it with:

ctl.ItemData(i)
 

Users who are viewing this thread

Top Bottom