Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need help with poker hands code

MORITSUKIMORITSUKI Posts: 0Member

Here is what I have so far [code] Public Class PokerHands

Sub InputFormat() 'Function to remove space and change characters to UPPER CASE InputDisplay.Text = InputDisplay.Text.Replace(" ", "").Replace(",","").ToUpper End Sub

Sub FourOfaKind() 'Four of a Kind

End Sub

Sub ThreeOfaKind() 'Three of a Kind

End Sub

Sub Pair() 'A pair

End Sub

Sub Flush() 'A flush

End Sub

Sub Straight() ' A straight, if ace is low

End Sub

Sub AceStraight() 'An ace-high straight; 10, J, Q, K, A

End Sub


Private Sub InputDisplay_TextChanged(ByVal sender As Object, e As EventArgs) Handles InputDisplay.TextChanged



End Sub

Private Sub Button1_Click(ByValsender As Object, e As EventArgs) Handles Button1.Click
    Dim hands(4, 13) As Integer 'Example: If (2,11) = 1 then is JD
    Dim SuitsValue() As String = {"S", "D", "C", "H"}

    Dim FaceValue() As String = {"2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"}
End Sub

End Class [/code]

Hi here is what I have my code so far. I am simply stuck as how to make the program reads the user input and then display the correpsonding deck. For example: if the user input "aH, AS, 2D, 3C, 4C" the program will return ace of hearts, ace of spades, two of diamonds, three of clubs, and four of clubs? Also how can the program will recognize that the first letter (substring (0,1) is the FaceValue and the second letter substring(1,1) is the SuitsValue? I understand I will need a loop function to determine all five. I am sorry if I am asking stupid questions here but I am really stuck!!!

Thank you very much!

Comments

  • hardwarehenryhardwarehenry GermanyPosts: 2Member
    edited July 14

    Here is a small sample with 1 button and four Textboxes : Public Class Form1 Public SuitsHands(4, 13) As Integer 'Example: If (2,11) = 1 then is JD Public SuitsValue() As String = {"S", "D", "C", "H"}

    Public FaceValue() As String = {"2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"}
    
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    
        Dim Userinput As String = "aH"
        Dim CheckInput As String
    
    
        CheckInput = "SDCH23456789TKQKA" ' allowed Chr
    
        ' now check if allowed
        If InStr(1, CheckInput, Mid(UCase(Userinput), 1, 1)) > 0 And InStr(1, CheckInput, Mid(UCase(Userinput), 2, 1)) Then
            ' face and value allowed
    
    
        Else
            ' not allowed Input
            MsgBox("Wrong Input")
    
            Exit Sub
    
        End If
    
    
        ' Value
        TextBox1.Text = Mid(CheckInput, InStr(1, CheckInput, Mid(UCase(Userinput), 1, 1)) - 4, 1)
        ' Suits 
        TextBox2.Text = Mid(CheckInput, InStr(1, CheckInput, Mid(UCase(Userinput), 2, 1)), 1)
        ' Value Position in FaceValue
        TextBox3.Text = "" & InStr(1, CheckInput, Mid(UCase(Userinput), 1, 1)) - 4
        ' Suits Position in uitsValue
        TextBox4.Text = "" & InStr(CheckInput, Mid(UCase(Userinput), 2, 1))
    
    
    
    
    
    
    
    
    
    
    End Sub
    

    End Class

  • hardwarehenryhardwarehenry GermanyPosts: 2Member
    edited July 14

    I only see the first 5 lines i sent hope you see the rest too

Sign In or Register to comment.