Private Type stu
num As Long
age As Integer
sex As String
End Type
Private Sub Command1_Click()
Dim a() As stu
For i = 0 To 5
ReDim Preserve a(i)
With a(i)
.age = 12
.num = i + 1
.sex = "男"
End With
Next i
Open App.Path & "\t.txt" For Random As #1
For i = 0 To 5
Put #1, , a(i)
Next i
Close #1
End Sub
Private Sub Command2_Click()
Dim b As stu
Open App.Path & "\t.txt" For Random As #1
Get #1, Val(Text1.Text), b
Close #1
MsgBox b.age
End Sub