Tuesday, 13 May 2014

QTP-UFT-How do you reverse a given String using VBS



How do you reverse a given String using VBS or QTP/UFT


Consider a variable 'a' to which we assign the input string. Input string in our case is "UFTQUESTIONS"


Approach 1
Use the StrReverse method

Script
a = "UFTQUESTIONS"
b= StrReverse(a)
msgbox b


Approach 2

Script
a="UFTQUESTIONS"
b=""
For i=0 to len(a)-1
    p=mid(a, len(a)-i, 1)
    b=b+p
Next
msgbox b

 
 
Output will be kept in variable 'b'
 

No comments:

Post a Comment