Results 1 to 5 of 5

Thread: [RESOLVED] Listbox - Take first item in list?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Resolved [RESOLVED] Listbox - Take first item in list?

    How do I extract the first line in a listbox? I know that to take data out you use lstBox.Text, but how do I automatically select line 1 before doing this?
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Listbox - Take first item in list?

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. List1.ListIndex = 0
    4.  
    5. End Sub

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Listbox - Take first item in list?

    This is very weird...because I tried that, and list1.listindex keeps on turning into -1 which is messing with the code I am trying to do :-)

    Edit: Me doing my usual FUBAR stuff...t'was a bug elsewhere...the listindex is of course firing the list1_click which is doing stuff which ruins it all...easy to fix...thanks for the help :-)
    Last edited by smUX; Jun 13th, 2006 at 07:58 PM.
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: [RESOLVED] Listbox - Take first item in list?

    Just a point. You may want to check that there is something in the ListBox first:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5.     If List1.ListIndex > -1 Then List1.ListIndex = 0
    6.  
    7. End Sub

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: [RESOLVED] Listbox - Take first item in list?

    Quote Originally Posted by Bruce Fox
    Just a point. You may want to check that there is something in the ListBox first:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5.     If List1.ListIndex > -1 Then List1.ListIndex = 0
    6.  
    7. End Sub
    Yeah, I was doing that...the issue wasn't that, it was something to do with me using .removeitem afterwards in a sub which was messing with it or something
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

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