Well, I acted too soon once again. Zvoni's suggestion on the command1 click event almost works. It does not ELIMINATE the chosen category for subsequent randomizing. Here is the code (all in project). Does anyone have a suggestion on how to eliminate categories as each textbox category is replaced with an X or an O. Still working on a second listbox to do the subsequent shuffling, and then repopulating list1, keeping in list1, the UNCHECKED categories (which would not be used in populating the textboxes.
Again, I have command1, list1, option1(0 and 1) and text1(0-8)..and soon to have list2 to try to shuffle and repop list1. Feel free to copy the code and test yourselves....:-)
Again, I have command1, list1, option1(0 and 1) and text1(0-8)..and soon to have list2 to try to shuffle and repop list1. Feel free to copy the code and test yourselves....:-)
Code:
Option Explicit
Private Sub Command1_Click()
RandomizeListBox
Dim x As Integer
'*********Populate textboxes with entries in listbox1
Dim j As Long
j = 0
For x = 0 To 8
If Text1(x).Text <> "X" And Text1(x).Text <> "O" Then
Text1(x) = List1.List(j)
List1.Selected(j) = True
j = j + 1
Text1(x).FontSize = 24 'to adjust for smaller fonts to fit into multiline textboxes
Else
Text1(x).FontSize = 48 'to adjust for larger fonts
End If
Next x
End Sub
Private Sub RandomizeListBox()
'****reorder list1 randomly*******************************
Dim x As Integer, y As Integer, colTemp As New Collection
For x = 0 To List1.ListCount - 1
colTemp.Add List1.List(x)
Next
List1.Clear
Do While colTemp.Count
y = Int((colTemp.Count * Rnd) + 1)
List1.AddItem colTemp(y)
colTemp.Remove y
Loop
End Sub
Private Sub Form_Load()
resetBoardToStart 'Sets "1" through "9" as displayed texts on text1() array
popListBox 'Initially sets up Categories to use for questions
Randomize
End Sub
Private Sub resetBoardToStart() ' 'Sets/Resets "1" through "9" as displayed texts on text1() array
Dim x As Integer
For x = 0 To 8
Text1(x).Text = Str(x + 1)
Next x
End Sub
Private Sub popListBox() 'Categories for questions-will be populated from ACCESS DB in future
Dim x As Integer
List1.AddItem ("WORLD WAR II")
List1.AddItem ("COMIC STRIPS")
List1.AddItem ("THE STAGE")
List1.AddItem ("FACES")
List1.AddItem ("AQUATIC BIOLOGY")
List1.AddItem ("WOMEN IN SONGS")
List1.AddItem ("US GEOGRAPHY")
List1.AddItem ("JUMP IN CATEGORY")
List1.AddItem ("WHO AM I?")
For x = 0 To 8
List1.ListIndex = x
List1.Selected(x) = True
Next x
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub Text1_Click(Index As Integer)
'*****Depending upon which of the two contestants are playing, put an X or an O in one of the nine textboxes
Dim myText As String, x As Integer, myArray(8) As Integer
myText = Text1(Index).Text
If Option1(0).Value = True Then 'Player # 1's turn
Text1(Index).Text = "X"
Else 'Player #2's turn
Text1(Index).Text = "O"
End If
'UNSELECTS the selected Category (of the original nine) from the listbox
For x = List1.ListCount - 1 To 0 Step -1
List1.ListIndex = x
If myText = List1.Text Or Text1(x).Text = "X" Or Text1(x).Text = "O" Then
' myArray(x) = List1.ListIndex
List1.Selected(x) = False
Else
List1.Selected(x) = True
End If
Next x
Text1(Index).FontSize = 48
End Sub