Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
An important update from QtpSudhakar. I stopped giving classroom training in MindQ Systems. I have bigger plans and I want to put an end to regular classroom training because very less people are practicing. From now onwards every session of mine is going to have explanation and practice. Everyone should practice in presence of mine and should go out of classroom with practical knowledge. So I started my own institute AnyTechLabs in Madhapur. Please reach out to +91-8328152362 for course details. Visit AnyTechLabs.com for address details.
Selenium + Cucumber 22nd September 9 AM IST to 2.00 PM IST 4 WeekEnds Theory + Practical AnyTechLabs
Selenium + Cucumber 8th October 7.30 AM IST to 9.00 AM IST 45 Days Theory+Practical AnyTechLabs

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