Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,547 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,838 people online right now. Registration is fast and FREE... Join Now!




VB6 Sorting

 
Reply to this topicStart new topic

VB6 Sorting, Sorting a 7 Card Texas Holdem Hand High to Low card

ca2nv
17 Aug, 2008 - 03:28 PM
Post #1

New D.I.C Head
*

Joined: 19 Jul, 2008
Posts: 5

I have a Texas Holdem application I've been working on. I've reached the point where I'm looking at the first hand (similar to this 7Q239K6)... I'm trying to sort it to look like..... KQ97632. I've worked with bubble sort before, but I've slept since then. After two days of working with the following code, I NEED HELP !

CODE

For i = 1 To 7
     hand(i) = Mid(Table_Surface.Text3(x + 10), i, 1)
Next
                    
        t = 1
        swap = 1
        Do Until t = 7
            For y = 1 To 7
                If hand(t) < hand(t + 1) Then
                                
                    HC = hand(t + 1): LC = hand(t)
                    hand(t) = HC: hand(t + 1) = LC
                                
                t = t + 1
                    Else
                    t = t - 1
                    SortedHand = SortedHand + hand(t)
                End If
                            
            Next
         Loop
            
         For i = 1 To 7
             Texas_Holdem.Text3(x) = Texas_Holdem.Text3(x) & hand(i)
         Next


I'm working with two forms..Table_Surface.Text3() and Texas_Holdem.Text3().

The first loop works fine and sets the hand up as dealt.
The next do/loop seems to be where the problem is.
The last loop will fill the textbox with sorted hand...........I HOPE.

This my first or second post, so I hope I have the Code area set up to display correctly

Any help will be much appreciated

Thanks

ca2nv




User is offlineProfile CardPM
+Quote Post

thava
RE: VB6 Sorting
17 Aug, 2008 - 05:56 PM
Post #2

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 450



Thanked: 18 times
Dream Kudos: 50
My Contributions
use this coding this is for bubble sort
CODE

Function bubbleSort(datastring As String)
For i = 1 To 7
     dataTmp(i) = Mid(datastring, i, 1)
Next
Do
nCount = nCount + 1
swap = False
For n = LBound(dataTmp) To UBound(dataTmp) - 1
If LCase(dataTmp(n)) > LCase(dataTmp(n + 1)) Then
tmp = dataTmp(n + 1)
dataTmp(n + 1) = dataTmp(n)
dataTmp(n) = tmp
swap = True
End If
Next n
Loop While swap = True

End Function


but there is one problem if you sorted it will be QK and so on what will you do
i think safely fixed the KD and sort the remaing
ie
CODE


For i = 1 To 7
   if val(Mid(datastring, i, 1)) <>0 then
     dataTmp(i) = Mid(datastring, i, 1)
   end if
Next


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:58PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month