Sorting

vb6 , web services United States
  • 18 years ago

    I am using VB3. With grid.vbx. I can Bubble sort a column OK, but how do I sort the rows as well. For example, I have columns Name Age Height. If I sort Height, how do I get the Name and Age sorted with the Height so that the rows are in the same order as the sorted Height?

  • 18 years ago

    I have written a resource to post on this site regarding sorting (using the quicksort algorithm), but it hasn't been posted yet.  Here is a link where you can go to download the program and copy my code (you'll have to modify it a little bit because the code is written to sort an Array).  SORTING PROGRAM

  • 18 years ago

    If they link says "Access Denied" or "Forbidden" then just reload the page.  It's because I can't link out to their server.  Most free web services control that sort of thing.  Sorry about the miscommunication.

  • 18 years ago

    DaddyLongLes, was it you i was supposed to be helping with this?


    If it was, sorry just have not had the time......



    Also i get the same problem with the above link, i need a fast sorting routine. I am using a bubble sort - not sure if this is the fastest way.


    Stevesoft

  • 18 years ago

    It seems that it is a must for now, so I'll check apoc's resource and try to approve by tomorrow.

  • 18 years ago

    You have this routine:


    Code:

    Sub SaveCurrentRecord()


       'Fill Person with the currently displayed data


       'Name
       Person.FileName = txtName.Text
       'Age
       Person.FileAge = txtAge.Text


       'Save Person to the current record.
       Put #FileNum, CurrentRecord, Person
       
    End Sub



    but i can't see where CurrentRecord is ever changed (increased) , so it seems to write to the same part of the file all the time. Should we not be increasing current record?


    also you have this:


    Code:

    Sub FillGrid()


       grdDummy.Row = CurrentRecord
       grdDummy.Col = 1
       grdDummy.Text = Person.FileName
       grdDummy.Col = 2
       grdDummy.Text = Person.FileAge


    End Sub



    but current record is always set to 1. so it always writes to the same row in the grid.


    Here we have a problem. For writing to the file we need to increase the current record by the recordlength, but for writing to the grid we need to increase the current record by 1.


    I think sorting the data is going to be easy, but first we need some data to sort. I am not trying to critises, i am just trying to help. It's quite difficult cause i don't have vb3.


    Give me your thoughts on the currentrecord variable, in the mean time i will keep looking at your code......


    Stevesoft

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann