List Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michels287
    New Member
    • Mar 2008
    • 20

    List Box

    Hello...

    I have 6 items in a list box. What code can I use for a button so that when I press the button the next item in the list box would be selected?

    And the other way around? What code can I use so that with a different button the previous item would be selected in the list box?

    Thanks!
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by michels287
    Hello...

    I have 6 items in a list box. What code can I use for a button so that when I press the button the next item in the list box would be selected?

    And the other way around? What code can I use so that with a different button the previous item would be selected in the list box?

    Thanks!
    Depends of the version, but in must versions, something like this will do:

    [CODE=vb]if listbox1.listin dex < listbox1.list.c ount -1 then
    listbox1.listin dex = listbox1.listin dex + 1
    end if

    'and for the previous

    if listbox1.listin dex > 0 then
    listbox1.listin dex = listbox1.listin dex - 1
    end if[/CODE]

    HTH

    Comment

    • michels287
      New Member
      • Mar 2008
      • 20

      #3
      This seems to work just fine! Thanks a lot!

      I am using VB6, by the way.

      Chris

      Comment

      Working...