I am terrible at figuring this stuff out and could use some help. I need to figure out all the possible combinations of a 4 card poker hand: Ad Ac Kd Ks . So it would be AcAdKsKd, KdAcKsAd, KsKdAcAd and so forth using the 4 different card strings. I think there are 24 different combos? I found some code here but I couldn’t get it to work right.

Hey. Yeah the order does not matter. I have a large text file I need to search thru but I cannot make heads or tails on how the card syntax is ordered…some have high cards first, some low and many in between so its kind of random. So the only way to do it is too run thru every possible ordering of the same hand.

Hey…yeah I know the total possible combinations but I need to know how to return the number of combinations of ONE 4 card hand as far as its ordering. So how would I return all of the combinations of AdAcKsKh ? It would be something like this:

AcAdKhKs, AcKhAdKs, KhAcKsAd, KhAcAdKs and so forth.

[quote=344985:@Michael Martz]Hey…yeah I know the total possible combinations but I need to know how to return the number of combinations of ONE 4 card hand as far as its ordering. So how would I return all of the combinations of AdAcKsKh ? It would be something like this:

AcAdKhKs, AcKhAdKs, KhAcKsAd, KhAcAdKs and so forth.

Thanks[/quote]

You are still using the word combinations where it appears you mean permutations. I’d suggest you read the link Norman gave above.

Hey…ok I get it now. I found this code and it works great:

[code]Function Permutations(s As String, delimiter As String = “.”) As String()
Dim tmpArr() As String
Dim perms() As String
Dim result() As String
Dim firstStr As String
Dim i As Integer
Dim j As Integer

tmpArr = Split(s, delimiter)

if tmpArr.Ubound <= 0 then
result.Append tmpArr(0)
else

firstStr = tmpArr(0)
tmpArr.Remove(0)
perms = Permutations(Join(tmpArr, delimiter))
for i = 0 to perms.Ubound
tmpArr = Split(perms(i), delimiter)
for j = 0 to tmpArr.Ubound + 1
tmpArr.Insert(j, firstStr)
result.Append(Join(tmpArr, delimiter))
tmpArr.Remove(j)
next j
next i

end if

return result

End Function[/code]

thanks for everybodys help in clarifying the difference between permutation and combination.