Reverse string - without Vb functions

3,802 views
Skip to first unread message

swetha4qtp delhi

unread,
Aug 28, 2009, 10:20:35 AM8/28/09
to Mercu...@googlegroups.com
Hello Group,

How can we Write code to reverse a string without using Vb functions. Is there any possibility of doing it with QTP Inbuild functions.


regards

swetha

Dhanasekar Subramaniam

unread,
Aug 28, 2009, 11:08:42 AM8/28/09
to mercu...@googlegroups.com
Swetha,
     You can store it in a array and reverse the array.

Dhanasekar S
http://testingides.wordpress.com


2009/8/28 swetha4qtp delhi <sweth...@gmail.com>



--
Regards,
Dhanasekar S.
http://testingideas.wordpress.com
---------------------------------------------------------
Let us make the World Greener
http://www.greenpeace.org/international/
-----------------------------------------------------------

swetha4qtp delhi

unread,
Aug 28, 2009, 12:00:04 PM8/28/09
to mercu...@googlegroups.com
I need  the code.

regards

swetha

Pradeep

unread,
Aug 28, 2009, 11:09:55 AM8/28/09
to mercu...@googlegroups.com
Hi swetha ,
        there is method "StrReverse" by this you can reverse string

2009/8/28 swetha4qtp delhi <sweth...@gmail.com>



--
Thanks & Regards,
 Pradeep. K

Subramanya aswath

unread,
Aug 28, 2009, 11:34:59 AM8/28/09
to mercu...@googlegroups.com

str="subramanya"
cnt=len(str)
for i=1 to cnt
revstr=mid(str,cnt+1-i,1)
ss=ss&vbtab&revstr
msgbox ss
next

On Fri, Aug 28, 2009 at 8:38 PM, Dhanasekar Subramaniam <dhana...@gmail.com> wrote:



--
Thanks and Regards
Subramanya.A

phaneendra theerdhala

unread,
Aug 28, 2009, 4:32:41 PM8/28/09
to mercu...@googlegroups.com
 
Suppose the string is "quicktest".
Use the following code to reverse it
 
str1 = "quicktest"
lenght = len(str1)
For i = lenght to 1 step -1
str2 = mid(str1,i,1)
str3 = str3&str2
Next
msgbox str3

 

Roman Zilber

unread,
Aug 28, 2009, 9:11:00 PM8/28/09
to mercu...@googlegroups.com
swetha,

Do you understand what you are asking?

Roman

swetha4qtp delhi

unread,
Aug 29, 2009, 3:30:55 AM8/29/09
to mercu...@googlegroups.com
Roman,

No . I coulnt get the Logic of the Code.

regards

Roman Zilber

unread,
Aug 29, 2009, 12:59:21 PM8/29/09
to mercu...@googlegroups.com
http://www.w3schools.com/vbScript/func_strreverse.asp
http://www.w3schools.com/vbScript/func_len.asp
http://www.w3schools.com/vbScript/func_mid.asp

all those are vbscript functions

Browser("Google").Page("Page_Google").Sync

Sync - QTP function.

Ravi kiran

unread,
Dec 14, 2012, 8:29:38 AM12/14/12
to mercu...@googlegroups.com
use below code to get string reverse

Dim yourstr,r,letter,result
 yourstr="ravi"
 Set r=new regexp
 r.pattern="[a-z 0-9 A-Z]"
 r.global=true
 set s=r.execute(yourstr)
 
For each i in s
 result= i.value&result
 Next



On Fri, Dec 14, 2012 at 5:30 PM, Veeranji Tirupati <veeru.t...@gmail.com> wrote:
Nani is correct

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Suresh Bhandari (Mahindra Satyam)

unread,
Dec 14, 2012, 9:56:52 PM12/14/12
to mercu...@googlegroups.com, mercu...@googlegroups.com
The Qtp or vbscript functions internally use Data Structure programming like 
Hash algorithm 
For sorting use 
Sorting algorithm 

So with the help of these we can made any of the function
So pls google how to use above for ur requirement 
 
 
Thanks & Regards
Suresh Bhandari

Naga Ganjala

unread,
Jul 25, 2014, 11:31:03 AM7/25/14
to mercu...@googlegroups.com
Dim yourstr,r,letter,result
 yourstr="ravi"
 Set r=new regexp
 r.pattern="[a-z 0-9 A-Z]"
 r.global=true
 set s=r.execute(yourstr)
 
For each i in s
 result= i.value&result
 Next

Can u pls any one explain this logic............ 

arun

unread,
Jul 28, 2014, 2:05:26 PM7/28/14
to mercu...@googlegroups.com
Hi Naga,

We have Regular Expression object(RegExp), it provides support for vb script also.

Dim yourstr,r,letter,result
 yourstr="ravi"               ' initialization of string
 Set r=new regexp        ' initializing RegExp object
 r.pattern="[a-z 0-9 A-Z]" ' Setting the pattern(regular expression for for all possible all alphabetical characters and numbers). we can specify whatever string we want to search in main string(yourstr) 
 r.global=true    ' making it to true - it returns all  results; False - only first result is returned
 set s=r.execute(yourstr) ' Execute method searches for pattern specified in yourstr variable, it returns a Matches  collection object, it contains Match objects.
 
For each i in s     ' iterating loop to read each Match object value
 result= i.value&result  ' Concatenating current value before result string, makes string reversed after the loop 
 Next

Now result string is having "ivar"

hope it is clear now. :)

Ashish Gupta

unread,
Jul 29, 2014, 2:55:45 AM7/29/14
to mercu...@googlegroups.com
Dim a,b,c,d,i
a=InputBox("Enter string")
b=Len(a)
For i=1 to b
c=Mid(a,i,1)
d=c&d
Next
msgbox d


No Need to use StrReverse here

Thanks,
Ashish gupta
Gurgaon,Haryana


--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

udayanem

unread,
Jul 29, 2014, 5:48:25 AM7/29/14
to mercu...@googlegroups.com
Hi Naga,

As per the pattern, it will get only single character. The character-set for consideration are a-z, A-Z, 0-9. So it consider only these sets.

Execute statement evaluates this expression and in the for loop, it gets single char. and the logic goes like this:
Initially result=null,
In the first iteration u will get single character, that is "r". This char is appended to result. So result=r
In the next iteration u will get next character, that is "a". This char is appended to result. So result=ar
In the next iteration u will get next char, that is "v". This char is appended to result, So result=var
In last iteration you will get "i" which is appended to result. So result will become "ivar"

Hope the above helps.

Thanks,
Uday
QTP / UFT Videos

shekhar bhakat

unread,
Jul 30, 2014, 5:40:29 AM7/30/14
to mercu...@googlegroups.com, Mercu...@googlegroups.com

Hi,

You can use regular expression .
Please find the following code to reverse a word,

a="shekhar"
set reg=new regexp
reg.pattern="[a-z A-Z]"
reg.global=true

set matchs=reg.execute(a)

for each match in matchs
    st=match&st
Next

msgbox"reverse string is   " & st

Please let me know if need clarification.
Reply all
Reply to author
Forward
0 new messages