CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: listbox help

  1. #1
    Guest

    listbox help

    how can I make it so that there is a list, called list1, with a number of items. The number of items varies. How can I make it so that I can erase all the items on a list1 from top to bottom. Here is the code I have got, but there is an error (see below):

    b = list1.listcount
    starting:
    list1.removeitem(b)
    if b=0 then goto ending
    b=b-1
    goto starting
    ending:

    it says that b is not compatible (ByRef Type Mismatch.) How could I do this?


  2. #2

    Re: listbox help

    You have to make b = to list1.listcount - 1, as the item index in a list box is 0 based.

    You probably also have to declare the variable

    Dim b as integer

    to avoid the type mismatch error


    Charles Zimmerman
    http://www.freevbcode.com


  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: listbox help

    DOnt put the braces!!.. yeah i think it is just that simple.
    ALso this code of yours doesn't remove the items from top-to-bottom ( well depends on what to refer as top) FOr me , top is first item in the list. it removes from bottom-up

    do
    list1.remove 0 ' because remove takes an index or an item to be removed .. may be!
    loop until list1.listcount = 0
    or some variant of this will remove from "top". .. from *my* top :-)



    RK

  4. #4
    Join Date
    Dec 1999
    Posts
    18

    Re: listbox help

    friend;
    by looking at your code i feel that you want to clear all the item in listbox .you can use the CLEAR method .and if you have any problem with removing any ITEM then you can refer the MSDN Knowledge BAse and see into HOWTO. section


    PAvan


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

Featured