Public Class Form1
    Inherits System.Windows.Forms.Form

    ' members...
    Private _userList As New ArrayList()


#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

    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

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

    '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.
    Friend WithEvents lstUsers As System.Windows.Forms.ListBox
    Friend WithEvents trkMinPasswordLength As System.Windows.Forms.TrackBar
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lstUsers = New System.Windows.Forms.ListBox()
        Me.trkMinPasswordLength = New System.Windows.Forms.TrackBar()
        CType(Me.trkMinPasswordLength, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'lstUsers
        '
        Me.lstUsers.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.lstUsers.Location = New System.Drawing.Point(16, 8)
        Me.lstUsers.Name = "lstUsers"
        Me.lstUsers.Size = New System.Drawing.Size(220, 186)
        Me.lstUsers.TabIndex = 2
        '
        'trkMinPasswordLength
        '
        Me.trkMinPasswordLength.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
        Me.trkMinPasswordLength.Location = New System.Drawing.Point(256, 8)
        Me.trkMinPasswordLength.Name = "trkMinPasswordLength"
        Me.trkMinPasswordLength.Size = New System.Drawing.Size(96, 42)
        Me.trkMinPasswordLength.TabIndex = 0
        Me.trkMinPasswordLength.Value = 6
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(368, 205)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.trkMinPasswordLength, Me.lstUsers})
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.trkMinPasswordLength, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim n As Integer
        For n = 1 To 100

            ' create a new user...
            Dim newUser As User
            newUser = User.CreateUser("Fred" & n, "password15")

            ' add it...
            _userList.Add(newUser)

        Next

        ' update the display...
        UpdateDisplay()
    End Sub


    Private Sub UpdateDisplay()

        ' clear the list...
        lstUsers.Items.Clear()

        ' add them...
        Dim user As User
        For Each user In _userList
            lstUsers.Items.Add(user.Username & ", " & user.Password & _
                     " (" & user.MinPasswordLength & ")")
        Next

    End Sub


    Private Sub trkMinPasswordLength_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trkMinPasswordLength.Scroll
        ' set the minimum password length...
        User.MinPasswordLength = trkMinPasswordLength.Value

        ' update the display...
        UpdateDisplay()
    End Sub


End Class
