identifying two pairs?

Keeper.001

New member
Joined
Jun 14, 2010
Messages
1
Programming Experience
Beginner
I need help identifying two pairs rather than a single one for a school project, Any ideas? Below is my code:


Option Strict On
Partial Class _Default
Inherits System.Web.UI.Page
Dim used(51) As Boolean
Dim deck(51) As String
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim w As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim i As Integer
For i = 0 To 51
used(i) = True
Next
End Sub
Private Function getRand() As Integer
Dim rand As New Random
Dim i As Integer
i = rand.Next(52)
While (Not used(i))
i = rand.Next(52)
End While
used(i) = False
Return i
End Function
Protected Sub btnDeal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeal.Click
Dim intCards(4) As Integer
intCards(0) = getRand()
picBox1.ImageUrl = "~/Pictures/" & intCards(0).ToString() & ".png"
intCards(1) = getRand()
picBox2.ImageUrl = "~/Pictures/" & intCards(1).ToString() & ".png"
intCards(2) = getRand()
picBox3.ImageUrl = "~/Pictures/" & intCards(2).ToString() & ".png"
intCards(3) = getRand()
picBox4.ImageUrl = "~/Pictures/" & intCards(3).ToString() & ".png"
intCards(4) = getRand()
picBox5.ImageUrl = "~/Pictures/" & intCards(4).ToString() & ".png"
Dim q As Integer = intCards(0)
Dim HoldCard As String = q.ToString()
Dim i As Integer
Dim iCount(12) As Integer
For i = 0 To intCards.Length - 1
If intCards(i) Mod 13 = 0 Then
iCount(0) = iCount(0) + 1
ElseIf intCards(i) Mod 13 = 1 Then
iCount(1) = iCount(1) + 1
ElseIf intCards(i) Mod 13 = 2 Then
iCount(2) = iCount(2) + 1
ElseIf intCards(i) Mod 13 = 3 Then
iCount(3) = iCount(3) + 1
ElseIf intCards(i) Mod 13 = 4 Then
iCount(4) = iCount(4) + 1
ElseIf intCards(i) Mod 13 = 5 Then
iCount(5) = iCount(5) + 1
ElseIf intCards(i) Mod 13 = 6 Then
iCount(6) = iCount(6) + 1
ElseIf intCards(i) Mod 13 = 7 Then
iCount(7) = iCount(7) + 1
ElseIf intCards(i) Mod 13 = 8 Then
iCount(8) = iCount(8) + 1
ElseIf intCards(i) Mod 13 = 9 Then
iCount(9) = iCount(9) + 1
ElseIf intCards(i) Mod 13 = 10 Then
iCount(10) = iCount(10) + 1
ElseIf intCards(i) Mod 13 = 11 Then
iCount(11) = iCount(11) + 1
ElseIf intCards(i) Mod 13 = 12 Then
iCount(12) = iCount(12) + 1
End If
Next i
Dim intHighest As Integer = iCount(0)
Dim intCount As Integer
For intCount = 1 To (iCount.Length - 1)
If iCount(intCount) > intHighest Then
intHighest = iCount(intCount)
End If
Next intCount
Dim strCards() As String = {"Aces", "Deuces", "Threes", "Fours", "Fives", "Sixes", "Sevens", "Eights", "Nines", "Tens", "Jacks", "Queens", "Kings"}
Dim x As Integer = 0
For i = 0 To 12
If iCount(x) = 2 Then
lblMessage.Text = "You have a pair of" & " " & strCards(x)
ElseIf iCount(x) = 3 Then
lblMessage.Text = "You have three of a kind of " & " " & strCards(x)
Else
lblMessage.Text = " "
x = x + 1
End If
Next
End Sub
End Class
Category
 
Back
Top