Scattergories help!!

ryanshui

New Member
Joined
Nov 5, 2011
Messages
1
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!!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top