Micro Focus QTP (UFT) Forums
extracting value from variable - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: extracting value from variable (/Thread-extracting-value-from-variable)



extracting value from variable - be_sure - 10-15-2008

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?


RE: extracting value from variable - somisays - 10-15-2008

Hi,

Please post the code so that we can help you.


RE: extracting value from variable - be_sure - 10-15-2008

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.


RE: extracting value from variable - Ankur - 10-16-2008

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



RE: extracting value from variable - be_sure - 10-21-2008

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


RE: extracting value from variable - satyadon - 10-21-2008

'sample code:

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


Regards
KrishDeep