Author Topic: Fast text file to string array routine for Visual Basic (VB6)  (Read 1355 times)

jj2007

  • Member
  • *****
  • Posts: 7559
  • Assembler is fun ;-)
    • MasmBasic
Fast text file to string array routine for Visual Basic (VB6)
« on: January 03, 2016, 11:37:42 PM »
With a few declarations and three lines of code, VB6 users can dramatically speed up their text to array code (to e.g. 8 ms/MB or 125kB/ms on an Intel i5):

Code: [Select]
    NumStrings = RecallMb("Bible.txt")
    ReDim Rec$(NumStrings)
    'SortMb         ' optional: sort strings alphabetically; ignore case and leading spaces
    SetStringsMb Rec$(0)

Sources and DLL attached. Of course, under the hood it's Recall().

Optionally, an equally fast sort algo is included.

For testing, you will need a huge text file, here are two suggestions:
http://patriot.net/~bmcgin/kjvpage.html
http://www.gutenberg.org/files/30/old/bible13.zip

EDIT: Masm4VB.zip contains a more advanced example. The *.asc source opens in RichMasm or Wordpad.
You can drag any text file over the exe, preferably a bible, because it searches for lines containing some keywords that appear more than once in the file, see ExtractDLinesMb in Form.
« Last Edit: January 05, 2016, 05:02:26 AM by jj2007 »