TheVampire
Programmer
I can save the state of selected items in a checkbox style list like this:
Dim Total As Variant
Dim I As Integer
Total = CDec(0)
For I = 0 To List1.ListCount - 1
If List1.Selected(I) = True Then
Total = Total + (2 ^ I)
End If
Next I
Then I can save the value of total.
I can retrieve the value and set the list like this:
For I = 0 To List1.ListCount - 1
If (Total And (2 ^ I)) = (2 ^ I) Then
List1.Selected(I) = True
Else
List1.Selected(I) = False
End If
Next I
This works fine up to 94 items in the list.
Does anyone have a solution to store the state in a single variable if I have more than 94 items?
( I know, having this many items in a single listbox isn't very good design, but circumstances are forcing this on me... )
One way I thought of was to have a string of 0's and 1's, and each one would indicate the state of the corresponding list item.
I could also divide the list up into 2 or more parts and save each part like I showed above ( but that takes more code and more room in the database, etc. ). Plus I really don't know what the eventual total # of items in the list may be . ( although I'm pretty sure it won't be more than 200 or so... )
Just looking for the most efficent way to do it!
Robert
Dim Total As Variant
Dim I As Integer
Total = CDec(0)
For I = 0 To List1.ListCount - 1
If List1.Selected(I) = True Then
Total = Total + (2 ^ I)
End If
Next I
Then I can save the value of total.
I can retrieve the value and set the list like this:
For I = 0 To List1.ListCount - 1
If (Total And (2 ^ I)) = (2 ^ I) Then
List1.Selected(I) = True
Else
List1.Selected(I) = False
End If
Next I
This works fine up to 94 items in the list.
Does anyone have a solution to store the state in a single variable if I have more than 94 items?
( I know, having this many items in a single listbox isn't very good design, but circumstances are forcing this on me... )
One way I thought of was to have a string of 0's and 1's, and each one would indicate the state of the corresponding list item.
I could also divide the list up into 2 or more parts and save each part like I showed above ( but that takes more code and more room in the database, etc. ). Plus I really don't know what the eventual total # of items in the list may be . ( although I'm pretty sure it won't be more than 200 or so... )
Just looking for the most efficent way to do it!
Robert