Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Listbox Usage

Hi I have a pair of listboxes with two lists in them. The first
listbox allows for multiple selection, the second does not. The items
in the second listbox are unchanging. The user selects one or more
items in the first listbox and then one item in the second and this
sets a pairing that is used elsewhere in the code.

My problem is this. As items are selected in the first list, I remove
them from the overall list by checking in reverse order (e.g. From
UserForm.Listbox.ListCount - 1 to 0 Step -1) if an item was selected.
If it is, I then go about a loop where every item is moved up one on
the list and then the last item is set to = "". I do this in a temp
array, redimming the array after its completely looped through all the
items in the list, clearing the listbox and then setting it back up by
setting it equal to the array.
The problem is, I seem to randomly get the "" at the back end of the
listbox. Its like the array isn't redimming. If I redim a 1D array to
a smaller size, shouldn't it just drop all the items at the end?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Listbox Usage

I suspect there is an error in the logic of the code that reorganizes the
array. This would be an easy mistake to make. Yes, redimming a 1D array to
a smaller size will drop the elements off the end

--
Regards,
Tom Ogilvy

"Marston" wrote in message
om...
Hi I have a pair of listboxes with two lists in them. The first
listbox allows for multiple selection, the second does not. The items
in the second listbox are unchanging. The user selects one or more
items in the first listbox and then one item in the second and this
sets a pairing that is used elsewhere in the code.

My problem is this. As items are selected in the first list, I remove
them from the overall list by checking in reverse order (e.g. From
UserForm.Listbox.ListCount - 1 to 0 Step -1) if an item was selected.
If it is, I then go about a loop where every item is moved up one on
the list and then the last item is set to = "". I do this in a temp
array, redimming the array after its completely looped through all the
items in the list, clearing the listbox and then setting it back up by
setting it equal to the array.
The problem is, I seem to randomly get the "" at the back end of the
listbox. Its like the array isn't redimming. If I redim a 1D array to
a smaller size, shouldn't it just drop all the items at the end?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Multicolumn Listbox and ordinary listbox Ron_D Excel Programming 0 June 4th 04 08:56 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"