Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
extracting value from variable
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi all, In QTP I have a variable and it has stored "123456" (including the double quotes) and when I am comparing this variable to other variable which has 123456 (same number without double quotes) it is failing the script. What are the solutions to solve this problem.
When I want to split the first variable with delimiter " I am getting error. What is the solution for using " as delimiter?
Please answer my little queries?
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,

Please post the code so that we can help you.
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi sridhar, I don't have Net access at work to post the code, so I am posting this query and reply from my blackberry mobile. The thing is let's say StrAlpha has the value "12345" and the same value stored in the history page of the application is extracted as just 12345 and stored into StrBeta and at the end two are compared and has to pass the script. But it is failing becoz of " (double quotes). I hope this is clear. Waiting for replies.
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
Yes, it's always good and easier for everyone when we have code in front of us.

This might help you:

Code:
x= """Ankur"""
y = Len(x)

z=mid(x,2, (y-2))  'Remember: y-2 is the no of characters including and after the 2nd position

msgbox  z
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi all,
Thanks to all u have posted the answers. Today i have checked with my senior most QTP professional (English Man) and he has given me the solution that one value was stored as string and other was stored as integer. So he suggested me to use either CInt(Str variable) or CStr(Int variable). I am telling this solution so that if some one faces tha same prolbme they can use either of them.

Thanks for you help
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
'sample code:

x= "123456"
y = 123456
If Strcomp(x,y)=0 Then
msgbox "Pass"
Else
msgbox "Fail"
End If


Regards
KrishDeep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)