Micro Focus QTP (UFT) Forums
Urgent help on declaring a 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Urgent help on declaring a variable (/Thread-Urgent-help-on-declaring-a-variable)



Urgent help on declaring a variable - swetha.b - 12-07-2009

Hi All,

Here is my code on a simple calculator application.
I am using QTP 9.2.

Option Explicit
Code:
SystemUtil.Run "calc.exe"
Dim click1,click2, click3, click4,result
click1= inputbox("Enter 1st number")
click2= inputbox("Enter 2nd number")
click3= inputbox("Enter 3rd number")
click4= inputbox("Enter 4 th number")
Window("Calculator Plus").WinButton(Cstr(click1)).Click

Quen: cant I pass the variable click1 directly to the statement with out giving Cstr? Window("Calculator Plus").WinButton(click1).Click

But the problem is even I give Cstr, QTP shows an error at this statemnt- object "4" is not found ....

Could any body help me ASAP please

Thanks
Swetha


RE: Urgent help on declaring a variable - sreekanth chilam - 12-07-2009

Hi swetha,

It looks a bit strange to me !!

I am using 9.5 V , Its working fine for me without "CSTR".
Hope you have added Calculator appl. Objects in Obj. Repo.

Code:
Option Explicit
SystemUtil.Run "calc.exe"
Dim click1,click2, click3, click4,result
click1= inputbox("Enter 1st number")
click2= inputbox("Enter 2nd number")
click3= inputbox("Enter 3rd number")
click4= inputbox("Enter 4 th number")
Window("Calculator").WinButton(click1).Click



RE: Urgent help on declaring a variable - venkatbatchu - 12-08-2009

[quote='sreekanth chilam' pid='9329' dateline='1260189945']
Hi swetha,
I am using QTP 9.2, I did not find any issues while executing and not seen ur issue.
Please check it once again.

Regards,
Venkat.Batchu


RE: Urgent help on declaring a variable - swetha.b - 12-08-2009

Hi sreekanth and Venkat,

Thank you for your responses. Yes it did work in 9.2 too. Sorry I put my application open for every run , in that way there were many calculators on the taskbar. This could have caused the problem.

Thanks again

swetha


RE: Urgent help on declaring a variable - sreekanth chilam - 12-08-2009

Hi Swetha,

Its good that you identified where it went wrong on your own.Smile

Sometimes you could find the Answer in your Questions itself.

@All: Hence request you to spend few mins for understanding the problem/issue before you post.