Tuesday, February 1, 2011

Verify Sorted Data

##############################################################
'#################### String Sort #############################
'##############################################################
 
'*************************************************************
' Function Name    : CheckStringSortAscending
' Parameter        : An Array contains list of strings
' Description      : This function checks the given list of 
'                    strings are in ascending order
'*************************************************************
 
Function CheckStringSortAscending(strArray)
 
Dim aIndex
 
CheckStringSortAscending=True
 
For aIndex=0 To UBound(strArray)-1
   If StrComp(strArray(aIndex),strArray(aIndex+1))>0 Then
           CheckStringSortAscending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************
 
'*************************************************************
' Function Name    : CheckStringSortDescending
' Parameter        : An Array contains list of strings
' Description      : This function checks the given list of 
'                    strings are in descending order
'*************************************************************
Function CheckStringSortDescending(strArray)
 
Dim aIndex
 
CheckStringSortDescending=True
 
For aIndex=0 To UBound(strArray)-1
   If StrComp(strArray(aIndex),strArray(aIndex+1))<0 Then
           CheckStringSortDescending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************
 
'##############################################################
'#################### Date Sort ###############################
'##############################################################
 
'*************************************************************
' Function Name    : CheckDateSortAscending
' Parameter        : An Array contains list of Date Values
' Description      : This function checks the given list of 
'                    Date values are in ascending order
'*************************************************************
 
Function CheckDateSortAscending(dtArray)
 
Dim aIndex
 
CheckDateSortAscending=True
 
For aIndex=0 To UBound(dtArray)-1
   If DateDiff("d",dtArray(aIndex),dtArray(aIndex+1))<0 Then
           CheckDateSortAscending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************
 
'*************************************************************
' Function Name    : CheckDateSortDescending
' Parameter        : An Array contains list of Date Values
' Description      : This function checks the given list of 
'                    Date values are in Descending order
'*************************************************************
 
Function CheckDateSortDescending(dtArray)
 
Dim aIndex
 
CheckDateSortDescending=True
 
For aIndex=0 To UBound(dtArray)-1
   If DateDiff("d",dtArray(aIndex),dtArray(aIndex+1))>0 Then
           CheckDateSortDescending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************
 
'##############################################################
'#################### Numeric Sort ############################
'##############################################################
 
'*************************************************************
' Function Name    : CheckNumericSortAscending
' Parameter        : An Array contains list of numbers
' Description      : This function checks the given list of 
'                    numbers are in Ascending order
'*************************************************************
 
Function CheckNumericSortAscending(numArray)
 
Dim aIndex
 
CheckNumericSortAscending=True
 
For aIndex=0 To UBound(numArray)-1
   If numArray(aIndex)>numArray(aIndex+1) Then
           CheckNumericSortAscending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************
 
'*************************************************************
' Function Name    : CheckNumericSortDescending
' Parameter        : An Array contains list of numbers
' Description      : This function checks the given list of 
'                    numbers are in Descending order
'*************************************************************
 
Function CheckNumericSortDescending(numArray)
 
Dim aIndex
 
CheckNumericSortDescending=True
 
For aIndex=0 To UBound(numArray)-1
   If numArray(aIndex)<numArray(aIndex+1) Then
           CheckNumericSortDescending=False
           Exit Function
   End If
Next
 
End Function
 
'*************************************************************

No comments:

Post a Comment