Hi,
I am trying to program the game "Scattergories" in Excel VBA. I am currently running into problems with checking user-inputted answers to the categories.
I have randomized the label captions on the userform to represent the different categories I have stored in an array like the following:
Categories(1) = "Countries"
Categories(2) = "Fruit"
CatNum = Int(Rnd * UBound(Categories())) + 1
Label7.Caption = Categories(CatNum)
The issue arises when I have to check the user answer. The current code is to check only the answer in the category "Countries". Is there anyway to make my checkAns function dynamic?
For i = 1 To UBound(Countries)
If Me.Controls("TextBox" & j).Text = Countries(i) Then
Check = True
Else: 'do nothing
End If
Next i
Is there anyway I could use the label caption that was generated randomly as an array name. i.e.
if Me.Controls("TextBox" & j).Text = Label7Caption (i) ?
I am relatively new at programming so any help would be greatly appreciated!! I am running into a few problems with the Scattergories game so any insight would be awesome!!
I am trying to program the game "Scattergories" in Excel VBA. I am currently running into problems with checking user-inputted answers to the categories.
I have randomized the label captions on the userform to represent the different categories I have stored in an array like the following:
Categories(1) = "Countries"
Categories(2) = "Fruit"
CatNum = Int(Rnd * UBound(Categories())) + 1
Label7.Caption = Categories(CatNum)
The issue arises when I have to check the user answer. The current code is to check only the answer in the category "Countries". Is there anyway to make my checkAns function dynamic?
For i = 1 To UBound(Countries)
If Me.Controls("TextBox" & j).Text = Countries(i) Then
Check = True
Else: 'do nothing
End If
Next i
Is there anyway I could use the label caption that was generated randomly as an array name. i.e.
if Me.Controls("TextBox" & j).Text = Label7Caption (i) ?
I am relatively new at programming so any help would be greatly appreciated!! I am running into a few problems with the Scattergories game so any insight would be awesome!!