Visual Basic Texas Holdem Code

CodeI'm writing a game of Texas Hold'Em in VB.NET and C#, and need to build some logic on calculating the resulting poker hand from a player's two cards and the cards on the table (totalling 7 in Texas Hold'Em).
For example:

Copy the code above. Open your workbook. Hit Alt+F11 to open the Visual Basic Editor (VBE). From the menu, choose Insert-Module. Paste the code into the code window at right. While in the VBE, choose Tools - References and put a check in MicroSoft Scripting Runtime. Close the VBE, and save the file if desired. Test the code.


This site lists a bunch of Poker Hand Evaluator libraries and gives a few details about each of them. Most of them are for 5 card hands, but there is at least one for a 7 card hand called The Snezee7 Evaluator. Poker game implementation. Ask Question Asked 4 years, 2. But what should be designed differently to approach my goals much easily and of course improved code quality. In my opinion there are 3 relevant classes. How many decks? If you have one deck of cards, you can have a maximum of 22 players (Texas hold em) or 5 players (5 card stud).

Players cards: 7H, JS
Cards on table: TD, 2H, 8H, 7C, 9S
In this case the player has a Jack high straight - 7H, 8H, 9S, TD, JS. The algorithm also has to discern that even though the player also has a pair (7H, 7C) the real hand is the straight.

Basic Texas Holdem Rules

I tried writing my own logic, but it ended up being 250+ lines of code by the time it could detect a royal flush. I've seen some code around that is meant to do it, but most of it is either in C/C++ or for other versions of poker.
I can write my own logic to discern a winner from a list of hands (i.e. that 3 of a kind beats two pair, and that an ace high straight beats a ten high straight). However, what I'm looking for is a function (or class) written in C# or VB.NET to return a poker hand (e.g. 'Two Pair - 3s and Jacks' or 'Four Aces') from a set of cards.Code

Texas Holdem Basic Strategy Chart

I've attached the VB.NET code for my structures and enums, but I can easily convert from another result format.

Texas Holdem Practice


Visual Basic Texas Holdem Code List

P: n/a
Hi Im an absolute beginner in programming and am using VB.Net Express.
To start my larning I decided to do a 'Real World' app instead of
'hello world' and am creating a Poker Countdown clock.
I pretty much have most things under control and have set it up as
follows:
Form 1 Contains a DataGridView where users enter in information
includeing the length of each round, small blind & big blind (its for
Texas Holdem Poker).
This then feeds the round information to Form2 which essential is the
display screen and includes the count down clock.
I can get it to read and run down the clock for the first round, but
am stumped on how I can get it to reset and pick up the infor for the
2nd and subsequant rounds.
I tried putting references back to the Timer1_Tick routine, but I get
an error message that says ' argument not specified for parameter 'e'
of Public Sub Timer1_Tick(sender as object, e as System.EventArgs).
I have listed the code (for form2) below and would appreciate any
feedback you can give me.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Class Form2
'Dim RoundLength As Integer = Form1.RoundLength
Dim RL As Integer = Form1.Round_InformationDataGridView.Item(1,
0).Value
Dim RoundLength As Integer = RL * 600
Dim RoundNumber As Integer = Form1.RoundNumber
Dim SmallBlind As Integer =
Form1.Round_InformationDataGridView.Item(2, 0).Value
Dim BigBlind As Integer =
Form1.Round_InformationDataGridView.Item(3, 0).Value
Dim NextSmall As Integer =
Form1.Round_InformationDataGridView.Item(2, 1).Value
Dim NextBig As Integer =
Form1.Round_InformationDataGridView.Item(3, 1).Value
Private Sub Form2_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Timer1.Enabled = False
Button1.Text = 'Start'
Button2.Text = 'Pause'
Label1.Text = '0' & RL & ':00'
Label2.Text = 'Round ' & RoundNumber
Label3.Text = SmallBlind
Label4.Text = BigBlind
Label5.Text = 'Next Small Blind ' & NextSmall
Label6.Text = 'Next Big Blind ' & NextBig
End Sub
Private CountDownStart
Private Sub button1_Click1(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Not Timer1.Enabled Then
CountDownStart = Microsoft.VisualBasic.DateAndTime.Timer
Timer1.Enabled = True
Button1.Text = 'Stop'
Button2.Text = 'Pause'
Button2.Enabled = True
Else
Timer1.Enabled = False
'MsgBox('Final Time: ' & Label1.Text & vbCrLf & vbCrLf &
'Click OK to reset the clock.')
Label1.Text = '0' & RL & ':00'
Button1.Text = 'Start'
Button2.Text = '-----'
Button2.Enabled = False
End If
End Sub
Private Sub Button2_Click1(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Static PauseInterval
If Timer1.Enabled Then
PauseInterval = Microsoft.VisualBasic.DateAndTime.Timer -
CountDownStart
Timer1.Enabled = False
Button1.Text = 'Restart'
Button2.Text = 'Resume'
Else
CountDownStart = Microsoft.VisualBasic.DateAndTime.Timer -
PauseInterval
Timer1.Enabled = True
Button1.Text = 'Stop'
Button2.Text = 'Pause'
End If
End Sub
Public Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim MinDiff
Dim SecDiff
Dim TenthDiff
Dim TimeDiff
'TimeDiff = (6000) -
Int((Microsoft.VisualBasic.DateAndTime.Timer - CountDownStart) * 10)
TimeDiff = (RoundLength) -
Int((Microsoft.VisualBasic.DateAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then
TenthDiff = TimeDiff Mod 10
SecDiff = Int(TimeDiff / 10) Mod 60
MinDiff = Int(TimeDiff / 600)
Label1.Text = Format(MinDiff, '00') & ':' &
Format(SecDiff, '00') '& '.' & Format(TenthDiff, '0')
Else
Label1.Text = '00:00'
Timer1.Enabled = False
'MsgBox('!!!TIME!!!')
RoundNumber += 1
Button1.Text = 'Start'
Button2.Text = '-----'
Button2.Enabled = False
Timer1_Tick()
End If
Application.DoEvents()
End Sub
End Class
--------------------------------------------------------------------------------------------------------------------------------------------------------------