Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listboxes fail to get .Values assigned (Xl2000&W98se, Xl2002&WMe)

    My 3 (single column) userform listboxes are all pre-populated by .Additem vba code with strings pulled from a large sheet (27000 rows, 30 columns, >5megabytes) and each gets a .Listindex set at a desired default item. And for debug I set the .Tag to the same string that was just .Additem'ed. Then, doing a Userform.Show displays exactly what it should. The listboxes all have the desired default item highlighted and all have all the items they should. (One funny is when I click the scroll down arrow, the box scrolls 3 items ONLY the first time this listbox is scrolled, and after that, scrolls one line like it should. Egad~!) Same for the other listbox with the large list (500 items).
    My real problem is that when I try to use the Listbox.Value before showing the form, (or after the user clicks OK, if the user has not changed the defaults), one or more Listbox.Values come back as "" instead of what they should have. It seems like excel is not realizing that it needs to stick a string into the .Listbox.Value place? Then when I try making mods to the code, the problem switches to a different listbox or listboxes without rhyme or reason.
    The Listbox.Tag has the correct string the whole time, but the .Value has a null string.
    The only workaround is if the user selects a different item than the highlighted default, and then selects the default again, and then all the Listbox.Values come back with the actual strings they should have!! - HELP! my hair is falling out fast enough on its own without a problem like this.!

  2. #2
    New Lounger
    Join Date
    Feb 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listboxes fail to get .Values assigned (Xl2000&W98se, Xl2002&WMe)

    OK, so am I nuts? The Listbox.Textcolumn is set to -1 (default for single column use), and when I set them all to ZERO, the Listbox.Values start showing up like they should - as strings. But the VBA help sez zero should give the .Listindex values, and -1 should give the first column with a .Columnwidth > 0. Of course, using single column mode, my Columnwidth is zero.

    Can anyone please explain?

    I am still woried that something is walking on something behind the scenes and this fix is a fluke. Besides, the user changing to another and then back also fixes the problem even with the
    -1 .Textcolumns.

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listboxes fail to get .Values assigned (Xl2000&W98se, Xl2002&WMe)

    Try using the .Text property instead of the .Value property.
    Legare Coleman

  4. #4
    New Lounger
    Join Date
    Feb 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listboxes fail to get .Values assigned (Xl2000&W98se, Xl2002&WMe)

    The .Text gives the same result as the .Value, ie; when the .Value is wrongly null, the .Text is also.

Posting Permissions

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