: let me ask my question like this
: i want to get 100 names and 100 scores of one hundred students
:
: wich one is better
:
:
: 'Module Code
: Private Type my record
: names As String
: scores As Single
: End Type
: public rec as my record
: 'main program Code
:
: put #1,,rec
:
: grant that #1 is a name of random file
: now check this:
:
: Private Type my record
: names(100) As String
: scores(100) As Single
: End Type
: public rec as my record
: 'main program Code
:
: put #1,1,rec
:
: the second one is rec with fileds:names and scores that ther are arrays
: and the record number is 1 when putting
:
:
: now i want to know wich one is better to use?
:
It is probably better to use the first one, as the second one simply gives you the ability to store 100 different names and 100 hundred different scores for EACH 'my record' (which should probably be 'my_record' by the way).
It seems to me, if you have 100 students for which you want to maintain a record of their name & score you would do something like this:
Private Type student_record
student_name As String
student_score As Integer
End Type
Dim my_students(99) As student_record 'Zero based array for 100 students
And then assign each record:
my_students(0).student_name = "Joe Smith" 'first student name
my_students(0).student_score = 85 'first student score
my_students(1).student_name = "Joe Jones" '2nd student name
my_students(2).student_score = 95 '2nd student score
On the other hand, if you want EACH RECORD to be able to hold 100 different names and 100 different scores, then the second example you gave is the way to go.