Sorting Question 
Author Message
 Sorting Question

Hello,

I have made a Hockey Pool program that stores people and there picks and their picks points. The program also needs to sort the people in order of their respected points. Then I print out the peoples names in that order and what their total points are. Now here is the problem, I can't get my sorting routine to work once compiled. It works no problem when I am in working on it in VB, but once compiled it does some really screwy things. Any advice, comments, suggestions would be greatly appreciated Here is the code, I hope you can understand it and it isn't too messy:

Sub Sort()
Dim numbers(0 To 100) As Integer
Dim x As Integer, y As Integer, lowPos As Integer, T As Integer, Z As Integer, DInt3 As Integer, DInt4 As Integer
Dim DInt1 As Integer, DInt2 As Integer

For T = 0 To UserNum 'Go through all the poeple in the pool
    numbers(T) = UserData(T).PTotal 'Add everyones total points to array numbers
    NumArray(T) = T 'Keep track of the persons number in NumArray
Next T

'This is my actual sorting routine...it is basically a copy of QuickBasics SWAP??? command
For x = 0 To UserNum - 1
        Let lowPos = x
    For y = x + 1 To UserNum
        If numbers(y) < numbers(lowPos) Then
             Let lowPos = y
        End If
       Next y
    DInt1 = numbers(x)
    DInt2 = numbers(lowPos)
    DInt3 = NumArray(x)
    DInt4 = NumArray(lowPos)

    numbers(x) = DInt2
    numbers(lowPos) = DInt1
    NumArray(x) = DInt4
    NumArray(lowPos) = DInt3
Next x

'this is just a temp file to see where the error is
Open "print.tmp" For Output As #1
    For Z = 1 To UserNum
        SortArray(Z) = numbers(Z)
        Print #1, SortArray(Z)
        Print #1, NumArray(Z)
    Next Z
Close #1
End Sub

Thanks a bunch in advance (I have been working on this prog. for over 8 months now and I can't seem to solve this problem)

BJ



Mon, 30 Jul 2001 03:00:00 GMT  
 Sorting Question

Quote:

> I have made a Hockey Pool program that stores people ...

How do you get the 'people' in there? ;-)
--

Sun Valley Systems    http://personal.bhm.bellsouth.net/~judmc
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."


Tue, 31 Jul 2001 03:00:00 GMT  
 Sorting Question

Define screwy, What exactly is happening with your arrays. I can't test whats happening without any data. In other words need more information.

Good Luck, Jimmy

    Hello,

    I have made a Hockey Pool program that stores people and there picks and their picks points. The program also needs to sort the people in order of their respected points. Then I print out the peoples names in that order and what their total points are. Now here is the problem, I can't get my sorting routine to work once compiled. It works no problem when I am in working on it in VB, but once compiled it does some really screwy things. Any advice, comments, suggestions would be greatly appreciated Here is the code, I hope you can understand it and it isn't too messy:

    Sub Sort()
    Dim numbers(0 To 100) As Integer
    Dim x As Integer, y As Integer, lowPos As Integer, T As Integer, Z As Integer, DInt3 As Integer, DInt4 As Integer
    Dim DInt1 As Integer, DInt2 As Integer

    For T = 0 To UserNum 'Go through all the poeple in the pool
        numbers(T) = UserData(T).PTotal 'Add everyones total points to array numbers
        NumArray(T) = T 'Keep track of the persons number in NumArray
    Next T

    'This is my actual sorting routine...it is basically a copy of QuickBasics SWAP??? command
    For x = 0 To UserNum - 1
        Let lowPos = x
        For y = x + 1 To UserNum
            If numbers(y) < numbers(lowPos) Then
        Let lowPos = y
        End If
        Next y
        DInt1 = numbers(x)
        DInt2 = numbers(lowPos)
        DInt3 = NumArray(x)
        DInt4 = NumArray(lowPos)

        numbers(x) = DInt2
        numbers(lowPos) = DInt1
        NumArray(x) = DInt4
        NumArray(lowPos) = DInt3
    Next x

    'this is just a temp file to see where the error is
    Open "print.tmp" For Output As #1
        For Z = 1 To UserNum
            SortArray(Z) = numbers(Z)
            Print #1, SortArray(Z)
        Print #1, NumArray(Z)
        Next Z
    Close #1
    End Sub

    Thanks a bunch in advance (I have been working on this prog. for over 8 months now and I can't seem to solve this problem)

    BJ



Tue, 31 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sort question on two fields

2. Excel sort question.

3. Outlook Group/Sort Question.

4. Collection sorting question

5. sorting question

6. sql sort question

7. Index and sorting question, help! :)

8. ACCESS Sorting question...

9. sorting question

10. List View Sort Question

11. Bubble sort question

12. MSFlexGrid Control - Sorting Question

 

 
Powered by phpBB® Forum Software