Results 1 to 9 of 9

Thread: [RESOLVED] listBox how to get specific items

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Resolved [RESOLVED] listBox how to get specific items

    well anybody know how can i get for example the second item from a listbox????????????
    Last edited by Hack; Mar 30th, 2006 at 10:48 AM. Reason: Added [RESOLVED] to thread title and green "resolved" checkmark

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: listBox how to get specific items

    MsgBox List1.List(1))
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: listBox how to get specific items

    syntax is
    control.List(position)
    position starts from 0 so, 2nd item means 1
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    55

    Re: listBox how to get specific items

    VB Code:
    1. msgbox Me.List1.List(1)

    If you wanted to msgbox out the third item:

    msgbox Me.List1.List(2)

    Obviously this is assuming your list is called List1.

  5. #5
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: listBox how to get specific items

    to get the second item from the listbox, do it like this
    VB Code:
    1. dim SecondVal As String
    2. SecondVal = list1.list(1)

    to get specific values in a listbox, use the list property and supply the index number of the data you want to retrieve

    the index starts with 0 so if the listbox has 5 items, the index would range from 0 to 4

    or 0 to list1.ListCount - 1
    ListCount returns the total number of items in your listbox
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  6. #6
    Hyperactive Member vbcode1980's Avatar
    Join Date
    Nov 2005
    Location
    Anywhere the wind blows
    Posts
    365

    Re: listBox how to get specific items

    Do you mean
    VB Code:
    1. MsgBox ListBox1.List(1)
    (The index starts at 0, so item 2 has index 1)
    I code C#....

  7. #7
    Hyperactive Member vbcode1980's Avatar
    Join Date
    Nov 2005
    Location
    Anywhere the wind blows
    Posts
    365

    Re: listBox how to get specific items

    Whoh, 5 similar posts in less than a minute
    I code C#....

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: listBox how to get specific items

    thanks...................

  9. #9
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: listBox how to get specific items

    then can you mark this thread as resolved. just see my signature <below the line after this message> for instructions on how to do it ok.
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

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