Results 1 to 4 of 4

Thread: ListBox as Function Parameter

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    4

    Angry ListBox as Function Parameter

    Hi there

    I have some Listboxes on my UserForm and I'd like to have a function that does something to them.

    Code:
    sub test (myListBox as ListBox)
    
    myListBox.addItem "test"
    
    end sub
    or something like this...

    when i call that function it tells me "runtime error 424: object needed" (or something similar, sry, i have the german version...)
    in debugging mode it tells me the listbox i try to edit is either Null, when its empty, or the item, that i added previously (in that case a string)

    ive already searched the internetz for this, and found some similar problems with solutions, like that the listbox isnt even a listbox but an msforms.listbox but this doenst work for me (same error)

    i dont get it, what im doing wrong...

    greetz

    Joshi

  2. #2
    New Member
    Join Date
    Aug 12
    Posts
    4

    Re: ListBox as Function Parameter

    by the was the exact same code works for a combobox...

  3. #3
    New Member
    Join Date
    Aug 12
    Posts
    4

    Re: ListBox as Function Parameter

    hmm, while testing i put parantheses around the object...

    so the error i get is no "424 runtime error", but a "runtime error 13: type mismatch" (or similar)

    sry...

  4. #4
    New Member
    Join Date
    Aug 12
    Posts
    4

    Re: ListBox as Function Parameter

    it works!

    seems like i made a mistake when i was trying around....

    msforms.listbox DOES indeed work, i was just too stupid to only change the type and not mess everything else up

    ty everyone who helped!

Posting Permissions

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