Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21920

Listbox Array problem

$
0
0
I have nn listboxes (List2) indexed 1, 2, 3, 4, 5,...,etc etc (index 0 not part of this)

I want to click on any item in List2 that currently is shown (all boxes in the array are one behind the other) and have it display the next listbox. It's fairly simple to do as long as all listboxes are still loaded. However any one or more of the listboxes can be unloaded and this is what is causing a problem. There is another listbox (List1) that keeps track of which listboxes are loaded and which are unloaded. If List2(5), for example, is unloaded then List1.List(4) will be unchecked otherwise List1.List(4) is checked

Below is code that I had which worked perfectly as long as all boxes still loaded

Code:

Private Sub List2_Click(Index As Integer)
  '
  '
 If Index + 1 > List2.Count - 1 Then Index = 0
 List2(Index + 1).ZOrder 0
  '
  '
End Sub

Now I had to modify the above code because it crashed on an Array not loaded error so the below code is how I modified it

Code:

Private Sub List2_Click(Index As Integer)
  '
  '
If Index + 1 > List2.Count - 1 Then Index = 0
 
If Not List1.Selected(Index) Then
  Index = Index + 1
  If Index > List2.Count - 1 Then Index = 0
End If
 
 
List2(Index + 1).ZOrder 0
  '
  '
End Sub

But it doesn't work. I need it to work like below:

1) Click on any list item in the currently shown listbox

2) Show the next listbox in the array

3) If the next listbox in the array is unloaded then skip to the next listbox after that

4) If next listbox afte that is also unloaded then skip to next. etc

Viewing all articles
Browse latest Browse all 21920

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>