Public Class Form1
  Inherits System.Windows.Forms.Form
  Private lsAdapter, ksAdapter As ListAdapter
  Private Swimmers As ArrayList
  Private Sub init()
    lsAdapter = New ListAdapter(lsNames)
    ksAdapter = New ListAdapter(lsKids)
    Swimmers = New ArrayList()
    ReadFile()
  End Sub
#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()
  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents lsNames As System.Windows.Forms.ListBox
  Friend WithEvents lsKids As System.Windows.Forms.ListBox
  Friend WithEvents Moveit As System.Windows.Forms.Button

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Moveit = New System.Windows.Forms.Button()
    Me.lsKids = New System.Windows.Forms.ListBox()
    Me.lsNames = New System.Windows.Forms.ListBox()
    Me.SuspendLayout()
    '
    'Moveit
    '
    Me.Moveit.Location = New System.Drawing.Point(152, 48)
    Me.Moveit.Name = "Moveit"
    Me.Moveit.Size = New System.Drawing.Size(56, 32)
    Me.Moveit.TabIndex = 2
    Me.Moveit.Text = ">>"
    '
    'lsKids
    '
    Me.lsKids.Location = New System.Drawing.Point(8, 24)
    Me.lsKids.Name = "lsKids"
    Me.lsKids.Size = New System.Drawing.Size(136, 173)
    Me.lsKids.TabIndex = 1
    '
    'lsNames
    '
    Me.lsNames.Location = New System.Drawing.Point(232, 24)
    Me.lsNames.Name = "lsNames"
    Me.lsNames.Size = New System.Drawing.Size(184, 173)
    Me.lsNames.TabIndex = 0
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(424, 229)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Moveit, Me.lsKids, Me.lsNames})
    Me.Name = "Form1"
    Me.Text = "ListDemo"
    Me.ResumeLayout(False)

  End Sub

#End Region
  Private Sub ReadFile()
    Dim s As String
    Dim sw As Swimmer
    Dim fl As New vbFile("swimmers.txt")
    fl.OpenForRead()
    s = fl.readLine
    While Not fl.fEOF
      sw = New Swimmer(s)
      Swimmers.Add(sw)
      ksAdapter.addItem(sw.getName)
      s = fl.readLine
    End While
  End Sub

  Private Sub Moveit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Moveit.Click
    Dim i As Integer
    Dim sw As Swimmer
    i = ksAdapter.ListIndex
    sw = CType(Swimmers(i), Swimmer)
    lsAdapter.addText(sw)
  End Sub
End Class
