By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,677 Members | 1,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,677 IT Pros & Developers. It's quick & easy.

Array in structure

P: n/a

I need to read fixed length records from a file. The record contains a fixed
sized table of another structure (let's say 100 elements).

I use the fileGet method to read the records with a structure.

The first problem I have is that I did not manage to define a fixed sized
array in the structure
structure Rec1
public tab as Rec2(100) 'Rec2 is another structure
end Structure
is not a valid syntax

I've then tried to do the following :
Structure Rec1
<VBFixedString(100*sizeofRec2)> tab as string
End Structure
in this case, I can read Rec1 correctly, but I can't figure out how to
extract the elements of type Rec2 in tab

Thanks for your help
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
You should be able to use the VBFixedArray for that:

Module Module1

Structure s1
<VBFixedArray(99)> Public arr() As s2
End Structure

Structure s2
Public i As Integer
End Structure

Sub Main()
Dim s1, s2 As s1
ReDim s1.arr(99)
ReDim s2.arr(99)
s1.arr(5).i = 42
FileOpen(1, "t.txt", OpenMode.Binary)
FilePut(1, s1)
FileOpen(1, "t.txt", OpenMode.Binary)
FileGet(1, s2)

End Sub

End Module

this will output and read back a structure containing an array of 100

Hope that helps,

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.