Dim iCheck, iStartCheck As Integer 'To check for successive unbridgable gaps in sequence
Dim iCount, iCount1, iMissing As Integer
Dim iExamined, iDiscards As Integer
Dim iAdjustCardCount As Integer = 0
Dim iZeroCount, iStraightCount, iFullStraight As Integer
Dim arriHand(7) As Integer ' To hold cards as dealt, sorted
Dim strMessage As String
arriHand(1) = 2
arriHand(2) = 3
arriHand(3) = 4
arriHand(4) = 5
arriHand(5) = 12
arriHand(6) = 13
arriHand(7) = 14
Dim arriHand1(15) As Integer 'Number of array element to indicate value of card dealt
For iCount = 0 To 7
arriHand1(arriHand(iCount)) = arriHand1(arriHand(iCount)) + 1
Next
If arriHand1(14) > 0 Then
iAdjustCardCount = 1
arriHand1(1) = arriHand1(14) 'If there is an Ace, place it in first position as well
End If
iMissing = 0
iCheck = 0
iStartCheck = 1
Do
'Check for existing straight 5 or straight 4
For iCount = iStartCheck To 14
If arriHand1(iCount) = 0 Then
iCheck = 0
Else
iExamined = iExamined + arriHand1(iCount)
iCheck = iCheck + 1
End If
Select Case iCheck
Case Is > 4
strMessage = "Straight Five Held"
Exit Do
Case Is > 3
strMessage = "Straight 5 Possible with 1 card"
If 7 + iAdjustCardCount - iExamined < 1 Then
Exit Do
End If
End Select
Next
'Check for 4 in sequence with 1 gap
iExamined = 0
For iCount = iStartCheck To 14
If arriHand1(iCount) > 0 Then
iExamined = iExamined + 1
Else
If iExamined > 0 Then
iMissing = iMissing + 1
If iMissing > 1 Then
iStartCheck = iStartCheck + 1
iCount = iStartCheck - 1
iExamined = 0
iMissing = 0
iDiscards = 0
For iCount1 = 1 To iCount
If arriHand1(iCount1) > 0 Then iDiscards = iDiscards + 1
Next
If iDiscards - iAdjustCardCount > 3 Then
strMessage = "Straight 5 Not Possible with 1 Card"
Exit Do
End If
End If
End If
End If
If iExamined = 4 Then
strMessage = "Straight 5 Possible with I card"
Exit Do
End If
Next
strMessage = "Straight 5 Not Possible with 1 card"
Exit Do
Loop
MessageBox.Show(strMessage)