Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
Selenium+Appium 16th October 2017 7.30 AM - 9.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur
Selenium+Appium 30th October 2017 9.30 AM - 11.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Thursday, July 28, 2011

Verify Data Sorting using VBScript

'##############################################################
'#################### 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(lCase(strArray(aIndex)),LCase(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(lcase(strArray(aIndex)),lcase(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

'*************************************************************
'#############################################################
_______________________________________
Please send your Suggestions and Doubts to my yahoo group http://in.groups.yahoo.com/group/qtpsudhakar

6 comments :

  1. i am very excited after seen this blog. it is very useful to beginners

    ReplyDelete
  2. How do we verify sorting order if the contains combination of alphanumerics
    eg: SC-150, SC-1

    ReplyDelete
  3. I need alpha numeric sort ascending and decending

    ReplyDelete
  4. I think string sorting is not right. U can not just convert the string to lower case and compare.because b and B has different ascii values.

    ReplyDelete
    Replies
    1. I am skipping case sensitivity in this sorting. Most of the times it is not required.

      Delete