Define text record with fields of defined length

  • Thread starter Thread starter DianePDavies
  • Start date Start date
D

DianePDavies

I have a text file where I read one line at a time.
I would like to define a data type like:

Type DataRec
Rectype as string(2)
name as string(12)
adress1 as string(30)
..
..
end type

dim DR as DataRec

by assigning the input line to a variable of the type DataRec I would like
to be able to get to the individual fields like:

name = DR.name

where DR.name is then having the appropriate value.

How do I define variable of a certain string-length?
 
DianePDavies said:
I have a text file where I read one line at a time.
I would like to define a data type like:

Type DataRec
Rectype as string(2)
name as string(12)
adress1 as string(30)
..
..
end type

dim DR as DataRec

by assigning the input line to a variable of the type DataRec I would like
to be able to get to the individual fields like:

name = DR.name

where DR.name is then having the appropriate value.

How do I define variable of a certain string-length?

Type DataRec
Rectype as string * 2
name as string * 12
adress1 as string * 30
..
..
end type

PS use something other than 'name' - that's a reserved word in Access and
will confuse things sooner or later.
 
now with my data structure defined - I would like to read my input record
"through" this data structure.

I read my text file line by line into a string called IDR and then I try this:

Dim IDR As String 'input data record
Dim DRp As DR1 ' data record - project

LSet DRp = IDR

DR1 is my user defined type of a certain length. The LSet statement results
in a "Type mismatch" error.

How do I get my input data into my data struture variable?
 
Back
Top