Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting File Contents with VB3

Status
Not open for further replies.

StuH

Programmer
Mar 25, 2001
53
AU
Hi all,

I have a need to sort a fixed-record length file (not an array), based on one or more sort criteria which need to be specified by the byte location and field length. For example, the file contains fixed-length records with a surname field that starts at say, byte 24 and is 30 bytes long.

I need every record sorted alphabetically based on these parameters and written back to that (or another temporary) file.

Does anyone know of a VBX or DLL that works with VB3 that will allow for this? Or perhaps you have a bit of magic code that will do it?

Any help is appreciated.

Regards,

Stu.
 
What have you written so far? any pseudo even??

--MiggyD It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Hi MiggyD,

No, I haven't done any code for it as yet. I was hoping there'd be a dll existing that I could use. Back in the dirty days of DOS and QuickBasic, I had an object called AS86M.OBJ - "AutoSort 86" that I linked into my BAS program that did exactly this. I was sure there would be something similar for VB, but as yet I can't find it.

The problem is, the files I need to sort may be up to 10MB in size (or more) with fixed 1300 byte records, so I probably couldn't read it all into an array.

Any help you may offer would be greatly appreciated.

Stu.
 
Hi StuH:

I only have VB4. The closest thing in VB4 is using ODBC and SQL statements, which I don't believe you have the luxury of. So, you'll probably have to construct your own.

I'd suggest that you set up a user TYPE to strip the trash you don't need from each record. open the file (first time in a series style) to gather each record into the TYPE you just DIM'd and at the same time store the TYPE's SurName stuff and the record # into a two DIM array. close the file (just incase of power failure).

Sort the 2 DIM'd array (lets call it 2dimd) on the lastname. Then open the data (this time in RANDOM style). Now, repeatedly go down the 2dimd array and get the record #. SEEK to that record, copy it to the temp file, and repeat the steps until done.

--MiggyD



It's better to have two heads to solve a problem from different angles than to have tunnel vision to a dead end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top