PDA

Click to See Complete Forum and Search --> : Read From TextFile


jhchia
Nov 21st, 1999, 05:36 PM
Hi everybody,
do you guys know how to use VB6 to read certain amount of characters from a textfile with a lot of characters in single line ? for example: a text file with 10,000 characters in single line and I want to get the first 1,000 characters only. if this way can be done in VB6 that could you please show me how to get subsequent characters in 1,000 character per read.
thanks.

Nov 21st, 1999, 06:20 PM
Open the file binary, preallocate a string and loop until you reach the end.


Dim iFileNummer As Integer
Dim lPos As Long
Dim sInput As String
Dim sTotal As String

iFileNummer = FreeFile
Open "C:\MyLargeFile" For Binary As #iFileNummer
For lPos = 1 To LOF(iFileNummer) Step 1000
sInput = Space(1000)
Get #iFileNummer, lPos, sInput
sTotal = sTotal & sInput
Next
Close #iFileNummer


Hope it helps.

------------------

Vincent van den Braken
EMail: azzmodan@azzmodan.demon.nl
ICQ: 15440110 (http://www.icq.com/15440110)
Homepage: http://www.azzmodan.demon.nl

spandex44
Nov 22nd, 1999, 03:31 AM
hi!
In C you can assign a length to a string. If you can do that somehow in vb, then you could set the length to 1,000 and then get that var from the text file. I've never tried this, but maybe it works.

Regards,
Alexander McAndrew
VB Zone http://gsenterprise.server101.com