Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Imports System
Imports System.Collections
Public Class YourClass: [b]Implements IComparable[/b]
Private _sErrorTitle As String
Private _sDisplayText As String
Public ReadOnly Property ErrorTitle() As String
Get
Return _sErrorTitle
End Get
End Property
Public ReadOnly Property DisplayText() As String
Get
Return _sDisplayText
End Get
End Property
Public Sub New(ByVal sErrTitle As String, ByVal sDisplayTxt As String)
Me._sErrorTitle = sErrTitle
Me._sDisplayText = sDisplayTxt
End Sub
Public Sub Dispose()
Me.Dispose()
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo
'Check to see if obj is actually your collection class
If Not (TypeOf obj Is YourCollection) Then
'If not throw an exception
Throw New ArgumentException
End If
Dim oObject As YourCollection = CType(obj, YourCollection)
Dim cmpl As Integer = Me.ErrorTitle.CompareTo(oObject.YourCollection)
If Not (cmpl = 0) Then
Return cmpl
End If
Return Me.YourPropertyName.CompareTo(oOBject.YourPropertyName)
End Function
Public Class YourClassCollection: Inherits CollectionBase
Public Sub New()
End Sub
Public Sub Dispose()
Me.Dispose()
End Sub
Default Public Property ErrorItems(ByVal idx As Integer) As FirstClassName
Get
'idx is the integer value of the index you are working with
Return CType(Me.InnerList(idx), FirstClassName)
End Get
Set(ByVal value As FirstClassName)
Me.InnerList(idx) = value
End Set
End Property
Public Sub Add(ByVal oObjectList As YourFirstClass)
Me.InnerList.Add(oObjectList)
End Sub
Public Sub Remove(ByVal oObjectList As YourFirstClass)
If Not Me.Contains(oObjectList) Then
Exit Sub
End If
Dim iCount As Integer = 0
While iCount < Me.InnerList.Count
Dim oNewObjectList As YourFirstClass = CType(Me.InnerList(iCount), oObjectList)
If oNewObjectList.CompareTo(oObjectList) = 0 Then
Me.RemoveAt(iCount)
Exit Sub
End If
System.Math.Min(System.Threading.Interlocked.Increment(iCount), iCount - 1)
End While
End Sub
Public Function ToArray() As YourFirstClass()
Return CType(Me.InnerList.ToArray(GetType(YourFirstClass)), YourFirstClass())
End Function
Private oErrorList As FirstClass
Private oError As New ClassCollection
Public Function GetList(ByVal sFile As String, ByVal sFileName As String, _
ByVal sTagName As String) As ErrCollection
'Check to make sure document exists
If Not File.Exists(sFile.TrimEnd) Then 'Document doesnt exist
'Write to error log
oEvents.WriteToLog(sFileName.TrimEnd & ".xml file not found.", "", sFileName.TrimEnd & ".xml Not Found.")
'Let the user knwo the problem
MsgBox("The text file could not be found." & vbCrLf & _
"Please contact your software support", MsgBoxStyle.Critical)
'Exit the function
Return Nothing
Exit Function
Else
'Open the XML document
xmlDoc.Load(sFile.TrimEnd)
Try
xmlDocNode = xmlDoc.GetElementsByTagName(sTagName.TrimEnd)
'Loop through all the nodes in the xml document
For Each xmlNewNode As Xml.XmlNode In xmlDocNode
'Create new collection object with the element values of the xml document
oErrorList = New ErrorList(xmlNewNode.Attributes("ErrorTitle").InnerText.TrimEnd, _
xmlNewNode.Attributes("DisplayText").InnerText.TrimEnd)
'Check to see if it already exists in the Collection
If Not oError.Contains(oErrorList) Then 'Doesnt contain
'So add it
oError.Add(oErrorList)
Else 'Contains this element already
'So remove it
oError.Remove(oErrorList)
End If
Next 'xmlNewNode
GetList = oError
Return GetList
Catch ex As Exception 'An Exception occurred
'Log the exception
oEvents.WriteToLog(ex.Message, ex.StackTrace, "ConvertXMLToCollection Error")
'Let the user know there was a problem
MsgBox("The XML Document could not be converted." & vbCrLf & _
"Please contact your software support", MsgBoxStyle.Critical)
'Exit the function
Return Nothing
Exit Function
Finally 'Do this no matter what
'Dispose of the objects
oErrorList.Dispose()
oError.Dispose()
sFile = String.Empty
sFileName = String.Empty
sTagName = String.Empty
End Try
End If
End Function
Private oError As New amaPNRError '(name of my collection)
Private oErrorList As ErrCollection '(Name of my collection)
oErrorList = oError.GetList(Application.StartupPath & "\LoginErrorList.xml", "LoginErrorList", "ErrorList")
For iCount As Integer = 0 To oErrorList.Count - 1
If Not ItHasErrors(oHost.LastResponse.Text, oErrorList.ErrorItems(iCount).ErrorTitle) = True Then 'No errors
_sErrMessage = EnumToText(9)
_bProcessComplete = True
_bHasErrors = False
Else
_sErrMessage = oErrorList.ErrorItems(iCount).ErrorTitle
_bProcessComplete = True
_bHasErrors = True
Exit Sub
End If
Next