Need help with poker hands code RRS feed

  • Question

  • User660470722 posted

    Here is what I have so far

     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

    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!

    Monday, July 14, 2014 5:26 AM


  • User-97501952 posted


    Based on your description, you want to know how to use loop to judge the first letter of user input is facevalue and the second letter of user input is suitvalue. I am not familar with VB, so I use C# console application to simulate this scene. Hope it can help you. And here is a VB sample for playing cards.


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
                string[] suitvalues= { "S", "D", "C", "H" };
                string[] facevalues={ "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A" };
                string inputvalue=Console.ReadLine();
                string inputv_1 = inputvalue.Substring(0,1);
                string inputv_2 = inputvalue.Substring(1,1);
                bool flag = true;
                for (int i = 0; i < facevalues.Length; i++)
                    if (inputv_1 == facevalues[i])
                        Console.WriteLine("the first letter is facevalues: " + facevalues[i]);
                 if (flag)
                            Console.WriteLine("the first letter "+inputv_1+ " is not facevalues!");
                bool flag2 = true;
                for (int i = 0; i < suitvalues.Length; i++)
                    if (inputv_2 == suitvalues[i])
                        Console.WriteLine("the second letter is suitvalues: " + suitvalues[i]);
                        flag2 = false;
                if (flag2)
                            Console.WriteLine("the second letter " + inputv_2 + " is not suitvalues!");


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 16, 2014 5:52 AM