Thursday, June 4, 2009

Displaying a Sentence( of words) in Reverse Order using QTP VB Scripting

str="I'm QuickTestProfessionall.Do you know me?"

arrStrings = Split(str,space(1))

msgbox ubound(arrStrings)


For each arrStr in arrStrings

vstrReverse = strReverse(arrStr) & space(1) & vstrReverse

msgbox arrStr'each string separated by a single space


msgbox vstrReverse


Public Function ReverseString(ByVal InputString As String) _
As String

Dim lLen As Long, lCtr As Long
Dim sChar As String
Dim sAns As String

lLen = Len(InputString)
For lCtr = lLen To 1 Step -1
sChar = Mid(InputString, lCtr, 1)
sAns = sAns & sChar

ReverseString = sAns

End Function

No comments:

Post a Comment