Showing posts with label count method. Show all posts
Showing posts with label count method. Show all posts

Saturday, 3 May 2014

QTP - UFT - Can you write a script to sort "uftquestions" as "efinoqssttuu"

One of the best method I would use for sorting is using object of "System.Collections.ArrayList"

Code:
Set o1 = Createobject("system.collections.ArrayList")
strInput = "UFTQuestions"
For k = 1 To len(strInput)
    o1.Add mid(strInput,k,1)
Next
o1.sort

For uj = 0 to o1.count-1
    strOutput = strOutput & o1(uj)
Next
msgbox strOutput

Output:- strOutput is "eFinoQsstTuU"

Happy reading,
Sreenu Babu

Sunday, 27 April 2014

QTP - UFT - How to count number of occurances of a string in a statement






We can use  regular expression.

Syntax
inputstring = "This String has multiple statements and each statement has multiple occurrences"
Set o1 = new RegExp
o1.pattern = "statement"
o1.ignorecase = true
o1.global = true
Set r1 = o1.execute(inputstring)
msgbox r1.count