Advertisement
Guest User

VB Royal Flush

a guest
Feb 11th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Private Function RoyalFlush(ByVal CardVal As Variant, ByVal CardSuit As Variant, ByVal CardSuitSorted As Variant)
  2.  
  3. Dim c, C1 As Integer
  4. Dim SuitCheck, CardLine, FlushSuit As Integer
  5. Dim ArrLength, ArrAdd As Integer
  6. ArrLength = -1
  7.  
  8. For c = 0 To 1
  9. SuitCheck = 0
  10.  
  11. For C1 = c To (c + 4)
  12. SuitCheck = IIf(CardSuitSorted(C1) = CardSuitSorted(C1 + 1), SuitCheck + 1, -100)
  13. Next C1
  14.  
  15. CardLine = c
  16. If SuitCheck = 5 Then Exit For
  17.  
  18. Next c
  19.  
  20. If SuitCheck <> 5 Then Exit Function
  21.  
  22. If CardLine = 0 Then FlushSuit = CardSuitSorted(0)
  23. If CardLine = 1 Then FlushSuit = CardSuitSorted(1)
  24. If CardLine = 2 Then FlushSuit = CardSuitSorted(2)
  25.  
  26. For c = 0 To 6
  27. If CardSuit(c) = FlushSuit Then CardVal(c).Tag = 1: ArrLength = ArrLength + 1
  28. Next c
  29.  
  30.  
  31. Dim ArrCheck() As Integer
  32. ReDim ArrCheck(ArrLength) As Integer
  33.  
  34.  
  35. For c = 0 To 6
  36. If CardVal(c).Tag = 1 Then
  37. ArrCheck(ArrAdd) = CardVal(c)
  38. ArrAdd = ArrAdd + 1
  39. End If
  40. Next c
  41.  
  42. Call Sort(ArrCheck)
  43.  
  44. RoyalFlush = IIf(ArrCheck(0) = 14 And ArrCheck(1) = 13 And ArrCheck(2) = 12 _
  45. And ArrCheck(3) = 11 And ArrCheck(4) = 10, 1, -1)
  46.  
  47.  
  48.  
  49. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement