|
-
Jul 13th, 2001, 02:25 AM
#1
Thread Starter
New Member
random access files
I'm converting an old DOS program written in Borland Turbo Basic to VB.
When using random access files, TB supports a FIELD statement which defines the field variables in the random access buffer. The FIELD statement uses the same file stream as the file being opened, so
FIELD #1 4 AS x$, 4 AS y$
would define the field as two variables.
You then simply GET the record, e.g.
rec=1000
GET #1, rec
which is written into the variables defined in the field.
What has happened to the FIELD statement in VB?
VB seems to want me to GET the field as a single variable, as in
GET #1, temptext
I'm trying to read the old DOS data file with VB and it keeps generating a "Bad Record Length" error. I am wondering whether or not this is because I have been unable to convert the FIELD statement?
Any help would be much appreciated.
Thanks in advance, David Atherton.
-
Jul 13th, 2001, 05:46 AM
#2
You need to use Type
Code:
' In the decraration part.
Type MyType
X As String * 4
Y As String * 4
End Type
' In a procedure.
Dim MT as MyType
Open File$ for Random Access Read As 1 Len = Len(MT)
Get #1, 1000, MT
Debug.Print MT.X
Debug.Print MT.Y
Close 1
Report any bugs to Microsoft 
DATA as been droped too, but that's a whole different story...
-
Jul 13th, 2001, 05:46 AM
#3
Well ...
I think you have to use the User-Defined Types available in VB.
Code:
Public Type MyField
X As Integer
Y As Integer
End Type
Dim MyType As MyField
For more details on manipulating the random access files, you can check out any tutorials on VB World or someone will help you out here.
PS: I guess the question has been answered already. Damn this slow connection!!
.
Last edited by honeybee; Jul 13th, 2001 at 06:13 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|