Results 1 to 10 of 10

Thread: delete 2nd last record in listbox.

  1. #1

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    delete 2nd last record in listbox.

    how to delete the 2nd last record in a listbox??
    i only know listbox.clear which will delete all record in a listbox.
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: delete 2nd last record in listbox.

    Try this...
    VB Code:
    1. listbox.removeitem listbox.listcount-2
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    Re: delete 2nd last record in listbox.

    thanks...how to cater the last record in a listbox??
    i tried this but got an error..

    listbox.list(listbox.listcount)
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete 2nd last record in listbox.

    Quote Originally Posted by Apek
    thanks...how to cater the last record in a listbox??
    i tried this but got an error..

    listbox.list(listbox.listcount)
    I'm not sure what you mean by 'cater', but if you are attempting to find out how many items are in a listbox, the syntax is:
    VB Code:
    1. Msgbox List1.ListCount

  5. #5

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    Re: delete 2nd last record in listbox.

    now i have 2 combobox..
    every item in the combobox that i click will be added in the listbox..
    let say i have added 2 items from 2nd combobox,so i want to capture what is the last item in the listbox...if the last item is coming from 1st combobox then it will do nothing but if the last item is coming from 2nd combobox i want to remove it.
    Last edited by Apek; Jul 18th, 2005 at 06:54 AM.
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete 2nd last record in listbox.

    Quote Originally Posted by Apek
    no..i want to detect what is the last record in the list...
    VB Code:
    1. Dim intLastRecord As Integer
    2. intLastRecord = List1.ListCount - 1
    3. MsgBox List1.List(intLastRecord)

  7. #7

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    Re: delete 2nd last record in listbox.

    hack..i just edited my post..maybe you might give different answer
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete 2nd last record in listbox.

    Quote Originally Posted by Apek
    now i have 2 combobox..
    every item in the combobox that i click will be added in the listbox..
    let say i have added 2 items from 2nd combobox,so i want to capture what is the last item in the listbox...if the last item is coming from 1st combobox then it will do nothing but if the last item is coming from 2nd combobox i want to remove it.
    I am so confused. If you are going to remove an item from your last box, then why are you bothering to add it in the first place?

    What is your end goal for all of this popping stuff all over everywhere?

  9. #9

    Thread Starter
    Hyperactive Member Apek's Avatar
    Join Date
    Aug 2002
    Location
    Kg Melayu,2 33 °N,102 10 °E
    Posts
    283

    Re: delete 2nd last record in listbox.

    actually i think i didn't deliver my problem very well.
    i will try again here.
    i want to remove it because maybe accidentally i choose a wrong item from the second combobox,and the item go to the listbox.
    so i have to choose an item again from the second combobox.
    but only one item from each combobox is allowed to be in the listbox.
    so thats why i want to remove the last item in the listbox which is wrongly inserted from 2nd combobox.
    i hope i clarify enough.if it still not clear i will explain again.
    "The reason you see open source there at all is because we came in and said there should be a platform that's identical with millions and millions of machines."
    Get it HERE


    Regards..
    Apek

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: delete 2nd last record in listbox.

    Quote Originally Posted by Apek
    thanks...how to cater the last record in a listbox??
    i tried this but got an error..

    listbox.list(listbox.listcount)
    VB Code:
    1. listbox.list(listbox.listcount-1)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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