Define text record with fields of defined length

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?
 
S

Stuart McCall

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.
 
D

DianePDavies

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top