Click to See Complete Forum and Search --> : File Reading


sripriya Gowri
June 14th, 2001, 06:39 PM
I have a file which has 10000 records.It is a tab delimited file.The file structure is as follows:Each record has 3 columns.The first column is a "FieldName" of length 50 characters,the second column is "Filenumber" of Integer type of length 2, the third is "Fieldnumber" of Integer of length 4.
In my application the user enters a string and I need to search for the similar occurences of the string in the above mentioned file.I need to display all the records with similar occurences in a MSflexgrid.
I am using VB 5.0 professional edition and can't use ADO.
Please give me the VB syntax of doing this without compromising the performance

Tower
June 14th, 2001, 07:29 PM
Define user type

Type YourRecord
FieldName as string*50
Filenumber as Integer
Fieldnumber as Integer
End Type



Open file in Random access mode

Dim f as Integer
F = FreeFile
Open "database.txt" for Random as f len=len(YourRecord)



Get any record
get #f, NumberRecord, YourRecord


After this code in YourRecord you see record number NumberRecord