VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Read a textfile via api calls (v1.1)

G. van den Hoven  (3 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This code is designed for reading text files. i have written this code because i did not want to use the slow "open for input..." and "freefile" bla bla code...
I know i coul do this via the richedit control, but i wanted to know how to do it via api, and maybe you to...
This code is using the "CreateFile" Api, which must be called differently in windows 2000. Therefore, i added a "IsWin2000" function to check for windows 2000.
Update: Now added a class which wraps the module, lot's of events and functionality. it's 50ms slower in read (with my test file)
Class module includes also function ReadCharacters which reads the specified ammount of characters from the open file.

Side Effects
You could get an "out of memory error" when you try to read text files larger then 32768 bytes, and put that into a textbox. Therefore, if you want to display text, use richedit boxes.

API Declarations
All in module, sample project included.

Rate Read a textfile via api calls (v1.1) (4(4 Vote))

Download Read a textfile via api calls (v1.1)

Read a textfile via api calls (v1.1) Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters