VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "KidData"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa KidData
Private kids As Collection
Private kd() As Kid
'------------------------------------------
Public Sub init(ByVal Filename As String)
  Dim k As Kid
  Set kids = New Collection
  Dim f As New vbFile
  Dim i As Integer
        
  f.OpenForRead Filename
  Dim s As String
  s = f.readLine()
  While Not f.fEof
    If (Len(Trim(s)) > 0) Then
      Set k = New Kid
      k.init s
      kids.add k
    End If
    s = f.readLine()
  Wend
  ReDim kd(kids.Count) As Kid
  For i = 1 To kids.Count
    Set kd(i) = kids(i)
  Next i
End Sub
'--------------------------------
Public Function getData() As Kid()
  getData = kd
End Function
'--------------------------------
Public Function size() As Integer
  size = kids.Count
End Function
'--------------------------------
Public Function getKid(ByVal i As Integer) As Kid
  getKid = kids(i)
End Function
'--------------------------------
Public Function getKidData(ByVal key As Integer) As Collection
  Dim i As Integer
  Dim v As New Collection
  For i = 0 To kids.Count - 1
    v.add (getKid(i).getData(key))
  Next i
  Set getKidData = v
End Function
'--------------------------------
Public Function getTableKey(ByVal tabName As String) As Integer
  Dim pv As New ParseVar
  Dim key As Integer
  key = -1
  tabName = LCase(tabName)
  Select Case tabName
    Case "frname"
      key = pv.FRNAME
    Case "lname"
      key = pv.LNAME
    Case "age"
      key = pv.AGE
    Case "club"
      key = pv.CLUB
    Case "time"
      key = pv.TIME
  End Select
        
  getTableKey = key
End Function
'----------------------------
Public Function getTableName(ByVal i As Integer) As String
  Dim pv As New ParseVar
  Dim name As String
  Select Case i
    Case pv.FRNAME
      name = "frname"
    Case pv.LNAME
      name = "lname"
    Case pv.AGE
      name = "age"
    Case pv.CLUB
      name = "club"
    Case pv.TIME
      name = "time"
  End Select
  getTableName = name
End Function
