Results 1 to 5 of 5

Thread: Listbox Error

  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Unanswered: Listbox Error

    I'm trying to add an item to a listbox and using the optional Index parameter. I keep getting the following error "Runtime error 5 - Invalid procedure call or argument". My code is simple.

    Dim iPlace as Integer
    Iplace=2
    ListBox(2).Add strOutputs, Iplace

    According to the help, setting the Index will put the added item in that position but I keep getting the error.

    What am I doing wrong?

    TIA
    David

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Try:

    listbox.additem stroutputs, iplace

  3. #3
    Join Date
    Dec 2003
    Posts
    14
    I should have gone back and corrected that but I was actually doing a
    listbox(2).AddItem strOutputs, iPlace

    but I believe I found the problem unless someone can tell me different but my listbox(2) was empty when I tried this. I had assumed, it would insert and add the previous indexs but I guess not.

    David

  4. #4
    Join Date
    Nov 2003
    Posts
    76
    you have to use listbox.newindex to use the index if you are not adding in order. or want to change

    listbox.add strOutputs
    listbox.ItemData(listbox.NewIndex)=iplace
    HTH

  5. #5
    Join Date
    Dec 2003
    Location
    P.R.C
    Posts
    1

    Re: Listbox Error

    Originally posted by vbnovice
    I'm trying to add an item to a listbox and using the optional Index parameter. I keep getting the following error "Runtime error 5 - Invalid procedure call or argument". My code is simple.

    Dim iPlace as Integer
    Iplace=2
    ListBox(2).Add strOutputs, Iplace

    According to the help, setting the Index will put the added item in that position but I keep getting the error.

    What am I doing wrong?

    TIA
    David
    Pass by

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •