VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsIconInfoCollection"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Private mo_colIconInfo As New Collection

'Constants
Private Const ms_UpperCharStart As String = "A"
Private Const ms_UpperCharEnd   As String = "Z"
Private Const ms_LowerCharStart As String = "a"
Private Const ms_LowerCharEnd   As String = "z"

Public Sub Add(as_Name As String, Optional ai_Code As Integer, Optional as_Description As String, _
                Optional as_Role As String, Optional as_Position As String)
    Dim lo_IconInfo As New clsIconInfo
    
    With lo_IconInfo
        .Name = as_Name
        .Code = ai_Code
        .Description = as_Description
        .Role = as_Role
        .Position = as_Position
        .Visible = True
    End With
    
    mo_colIconInfo.Add Item:=lo_IconInfo
    
End Sub


Public Function Remove(as_Name As String) As Boolean

    Dim li_Index As Integer
    
    For li_Index = mo_colIconInfo.Count To 1 Step -1
      If mo_colIconInfo.Item(li_Index).Name = as_Name Then
         mo_colIconInfo.Remove (li_Index)
         Remove = True
         Exit Function
      End If
    Next
    
    Remove = False
    
End Function

Public Sub RemovePosition(as_Position As String)

    Dim li_Index As Integer
    
    For li_Index = mo_colIconInfo.Count To 1 Step -1
      If mo_colIconInfo.Item(li_Index).Position = as_Position Then
         mo_colIconInfo.Remove (li_Index)
         Exit For
      End If
    Next
    
End Sub


'Public Sub Delete(as_Name As String)
'
'    Dim lo_IconInfo As New clsIconInfo
'
'    Set lo_IconInfo = Item(as_Name)
'
'    With lo_IconInfo
'        .Name = ""
'        .Code = 0
'        .Description = ""
'        .Role = ""
''        .Position = ""
'    End With
'
'End Sub

'Public Sub DeletePosition(as_Position As String)
'
'    Dim lo_IconInfo As New clsIconInfo
'
'    Set lo_IconInfo = ItemPosition(as_Position)
'
'    With lo_IconInfo
'        .Name = ""
'        .Code = 0
'        .Description = ""
'        .Role = ""
''        .Position = ""
'    End With
'
'End Sub
'
'
'Public Sub ClearEmptyIcons()
'
'    Dim li_Index As Integer
'    Dim lo_IconInfo As New clsIconInfo
'
'    For li_Index = mo_colIconInfo.Count To 1 Step -1
'      If mo_colIconInfo.Item(li_Index).Name = "" Then
'         mo_colIconInfo.Remove (li_Index)
'      End If
'    Next
'
'
'End Sub


Public Function Item(as_Name As String) As clsIconInfo
    Dim lo_IconInfo As New clsIconInfo
    
    For Each lo_IconInfo In mo_colIconInfo
        If (as_Name = lo_IconInfo.Name) Then
            Set Item = lo_IconInfo
            Exit Function
        End If
    Next
    
    Set Item = Nothing

End Function

Public Function ItemByRole(as_Role As String) As clsIconInfo
    Dim lo_IconInfo As New clsIconInfo
    
    For Each lo_IconInfo In mo_colIconInfo
        If (as_Role = lo_IconInfo.Role) Then
            Set ItemByRole = lo_IconInfo
            Exit Function
        End If
    Next
    
    Set ItemByRole = Nothing

End Function

Public Function ItemPosition(as_Position As String) As clsIconInfo
    Dim lo_IconInfo As New clsIconInfo
    
    For Each lo_IconInfo In mo_colIconInfo
        If (as_Position = lo_IconInfo.Position) And lo_IconInfo.Visible Then
            Set ItemPosition = lo_IconInfo
            Exit Function
        End If
    Next
    
    Set ItemPosition = Nothing

End Function


Public Property Get Items() As Collection
     Set Items = mo_colIconInfo
End Property

Public Function GetLastPosition() As String
    Dim ls_LastPosition As String
    Dim lo_IconInfo As New clsIconInfo
    
On Error GoTo ErrorHandler
  
    If mo_colIconInfo.Count > 0 Then ls_LastPosition = ms_UpperCharStart
    
    For Each lo_IconInfo In mo_colIconInfo
        If (lo_IconInfo.Position > ls_LastPosition) Then ls_LastPosition = lo_IconInfo.Position
    Next
        
    GetLastPosition = ls_LastPosition
    
    Exit Function
    
ErrorHandler:
    GetLastPosition = ls_LastPosition

End Function


Public Function GetNextPosition(as_Position As String) As String
    
On Error GoTo ErrorHandler
   
   If (as_Position = "") Then
      GetNextPosition = ms_UpperCharStart
   ElseIf as_Position = ms_LowerCharEnd Then
      GetNextPosition = ""
   ElseIf as_Position = ms_UpperCharEnd Then
      GetNextPosition = ms_LowerCharStart
   Else
      GetNextPosition = Chr(Asc(as_Position) + 1)
   End If
   
   Exit Function
   
ErrorHandler:
   GetNextPosition = ""
   
End Function
   
Public Function GetPreviousPosition(as_Position As String) As String
    
On Error GoTo ErrorHandler
   
   If (as_Position = "" Or as_Position = ms_UpperCharStart) Then
      GetPreviousPosition = ""
   ElseIf as_Position = ms_LowerCharStart Then
      GetPreviousPosition = ms_UpperCharEnd
   Else
      GetPreviousPosition = Chr(Asc(as_Position) - 1)
   End If
   
   Exit Function
   
ErrorHandler:
   GetPreviousPosition = ""
   
End Function
