Private Function NumberFormat(ByVal X As Double) As String
Dim Y As String
If X <= 10 Then
Select Case X
Case 1: Y = "one"
Case 2: Y = "two"
Case 3: Y = "three"
Case 4: Y = "four"
Case 5: Y = "five"
Case 6: Y = "six"
Case 7: Y = "seven"
Case 8: Y = "eight"
Case 9: Y = "nine"
Case 10: Y = "ten"
End Select
Else
Y = CStr(X)
End If
NumberFormat = Y
End Function
Private Function Capitalize(ByVal X As String) As String
Capitalize = UCase$(Left$(X, 1)) & Mid$(X, 2)
End Function
Private Sub GenerateBingoCard(Label As Object)
Dim i As Long
Dim Bingo As New clsBingo
For i = 0 To 24
If i = 12 Then
Bingo.GoNext
Label(i).ForeColor = vbRed
Else
Label(i) = CStr(Bingo.RandomNumber)
Label(i).BackColor = vbButtonFace
Label(i).ForeColor = vbButtonText
End If
Next
End Sub
Private Sub MarkOffBingoCard(Label As Object, ByVal Letter As String, ByVal DrawnNumber As Long)
Dim i As Long
Dim i0 As Long
Select Case Letter
Case "B": i = 0
Case "I": i = 5
Case "N": i = 10
Case "G": i = 15
Case "O": i = 20
End Select
For i0 = i To i + 4
If i0 <> 12 Then
If Label(i0) = CStr(DrawnNumber) Then
Label(i0).BackColor = vbBlack
Label(i0).ForeColor = vbRed
End If
End If
Next
End Sub
Private Sub CheckForWinningRows(Label As Object, bDidWin As Boolean, NumberAway As Long, Orientation As Long, WinningIdx1 As Long, WinningIdx2 As Long, WinningIdx3 As Long, WinningIdx4 As Long, WinningIdx5 As Long)
' Orientation:
' --------------
' 1 = Horizontal
' 2 = Vertical
' 3 = Diagonal
Dim i As Long
Dim j As Long
Dim bWinner As Boolean
Dim tNumAway As Long
NumberAway = 5
bDidWin = False
Orientation = 0
WinningIdx1 = 0
WinningIdx2 = 0
WinningIdx3 = 0
WinningIdx4 = 0
WinningIdx5 = 0
For i = 0 To 4
bWinner = True
tNumAway = 0
For j = 0 To 20 Step 5
If Label(j + i).BackColor <> vbBlack Then
bWinner = False
tNumAway = tNumAway + 1
End If
Next
If tNumAway < NumberAway Then NumberAway = tNumAway
If bWinner Then
bDidWin = True
Orientation = 1 ' Horizontal
WinningIdx1 = i
WinningIdx2 = i + 5
WinningIdx3 = i + 10
WinningIdx4 = i + 15
WinningIdx5 = i + 20
Exit For
End If
Next
If Not bWinner Then
For i = 0 To 20 Step 5
bWinner = True
tNumAway = 0
For j = 0 To 4
If Label(j + i).BackColor <> vbBlack Then
bWinner = False
tNumAway = tNumAway + 1
End If
Next
If tNumAway < NumberAway Then NumberAway = tNumAway
If bWinner Then
bDidWin = True
Orientation = 2 ' Vertical
WinningIdx1 = i
WinningIdx2 = i + 1
WinningIdx3 = i + 2
WinningIdx4 = i + 3
WinningIdx5 = i + 4
Exit For
End If
Next
If Not bWinner Then
bWinner = True
tNumAway = 0
For i = 0 To 24 Step 6
If Label(i).BackColor <> vbBlack Then
bWinner = False
tNumAway = tNumAway + 1
End If
Next
If tNumAway < NumberAway Then NumberAway = tNumAway
If bWinner Then
bDidWin = True
Orientation = 3 ' Diagonal
WinningIdx1 = 0
WinningIdx2 = 6
WinningIdx3 = 12
WinningIdx4 = 18
WinningIdx5 = 24
Else
bWinner = True
tNumAway = 0
For i = 4 To 20 Step 4
If Label(i).BackColor <> vbBlack Then
bWinner = False
tNumAway = tNumAway + 1
End If
Next
If tNumAway < NumberAway Then NumberAway = tNumAway
If bWinner Then
bDidWin = True
Orientation = 3 ' Diagonal
WinningIdx1 = 4
WinningIdx2 = 8
WinningIdx3 = 12
WinningIdx4 = 16
WinningIdx5 = 20
End If
End If
End If
End If
End Sub
Private Sub WinningCheckAction(Label As Object, ByVal LabelNum As Long)