Results 1 to 7 of 7

Thread: [RESOLVED] listboxes

  1. #1

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Resolved [RESOLVED] listboxes

    how do i define each item of a list, for example, if I had 5 items in a list, how would i be able to just take one of the items and msgbox its value?

  2. #2

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: listboxes

    hiya!
    VB Code:
    1. msgbox list1.list(x) 'Put any number or variabel where the x is
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: listboxes

    VB Code:
    1. MsgBox List1.List(0)

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: listboxes

    Quote Originally Posted by ajames
    how do i define each item of a list, for example, if I had 5 items in a list, how would i be able to just take one of the items and msgbox its value?
    Try this:

    VB Code:
    1. Private Sub Form_Load()
    2. Dim a As Long
    3.  
    4.     For a = 1 To 10
    5.         List1.AddItem "This is Item " & a
    6.     Next a
    7. End Sub
    8.  
    9. Private Sub List1_Click()
    10.     With List1
    11.         MsgBox "You Clicked on " & .Text & " which has and index of " & .ListIndex
    12.     End With
    13. End Sub
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  6. #6

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: listboxes

    thanks

  7. #7
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: [RESOLVED] listboxes

    Not bad four responses in less than two minutes.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


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