M
Michael J. Malinsky
I have a MultiSelect ListBox. I'd like to compare a VBA generated random
number with the selections in the ListBox to ensure validity. I am
currently using a loop to determine if the first item in the ListBox is
selected. If it is not selected, we move to the second item, etc. If it is
selected then we run and If...Then statement to check the random value
against the item selected in the ListBox. If the random value is not valid,
a new number must be generated by VBA. If the random number is valid, then
we check to ensure that the number has not been previously chosen (I use an
array to store the chosen numbers). If the number has not been previously
chosen, then we move on with life. If the number has already been chosen
then VBA must select another random number then we must start the process
over again to ensure that the new selected number is first valid against the
selected items in the ListBox then checking again for a duplicate value.
I was fine when I had a simple program to simply check for duplicate values.
VBA selected the number then I used a separate function to check for a
duplicate value. My problem started when I threw in the ListBox selection
section. I can't seem to come up with a fluid method of doing what I
described above. I can probably come up with the programming if someone can
help with the logic.
TIA
Mike.
number with the selections in the ListBox to ensure validity. I am
currently using a loop to determine if the first item in the ListBox is
selected. If it is not selected, we move to the second item, etc. If it is
selected then we run and If...Then statement to check the random value
against the item selected in the ListBox. If the random value is not valid,
a new number must be generated by VBA. If the random number is valid, then
we check to ensure that the number has not been previously chosen (I use an
array to store the chosen numbers). If the number has not been previously
chosen, then we move on with life. If the number has already been chosen
then VBA must select another random number then we must start the process
over again to ensure that the new selected number is first valid against the
selected items in the ListBox then checking again for a duplicate value.
I was fine when I had a simple program to simply check for duplicate values.
VBA selected the number then I used a separate function to check for a
duplicate value. My problem started when I threw in the ListBox selection
section. I can't seem to come up with a fluid method of doing what I
described above. I can probably come up with the programming if someone can
help with the logic.
TIA
Mike.