Public array to hold the new buttons class to allow each of the 25 to share the click event
Public aryQA(1 To 5, 1 To 5) As New clsCommandButton ' dollars as row, categories as columns
Loads the 25 button into the array
Private Sub StartButton_Click()
Dim c As Long, d As Long, i As Long
Load JHome
'only works because you have the controls named nice
For i = 0 To JHome.Controls.Count - 1
If JHome.Controls(i).Name Like "[A-E][1-5]00" Then
d = CLng(Right(JHome.Controls(i).Name, 3)) / 100 ' "300" = 300 / 100 = 3
c = Asc(Left(JHome.Controls(i).Name, 1)) - 64 ' "A" = 65, -64 = 1
Set aryQA(d, c).evtCommandButton = JHome.Controls(i)
End If
Next i
For d = 1 To 5
For c = 1 To 5
aryQA(d, c).evtCommandButton.Visible = True
aryQA(d, c).evtCommandButton.Enabled = True
Next c
Next d
JHome.FinalJeopardy.Visible = False
JHome.FinalJeopardy.Enabled = False
JHome.Show
Unload Me
End Sub
The new class to allow 25 buttons to share the same event code -- the DailyDouble doesn't work right since I didn't know
Option Explicit
Public WithEvents evtCommandButton As MSForms.CommandButton
Private Sub evtCommandButton_Click()
Dim c As Long, d As Long
c = Asc(Left(evtCommandButton.Name, 1)) - 64 ' "A" = 65, -64 = 1
d = CLng(Right(evtCommandButton.Name, 3)) / 100 ' "300" = 300 / 100 = 3
slide.Question = Final.Cells(d + 1, 2 * c - 1).Text
slide.Answer = Final.Cells(d + 1, 2 * c).Text
evtCommandButton.Visible = False
evtCommandButton.Enabled = False
If Final.Range("L1").Value = "1" Then
DailyDouble.Show
Else
slide.Show
End If
For d = 1 To 5
For c = 1 To 5
If aryQA(d, c).evtCommandButton.Visible Then Exit Sub
Next c
Next d
End Sub