Geeks Talk

Prepare for your Next Interview




how to return value from a function in QTP?

This is a discussion on how to return value from a function in QTP? within the QTP forums, part of the Software Testing category; below is giving error: Please correct them msgbox getSomething() A return type must be declared? Function getFlatRate() s = browser("B").Page("p").WebElement("we").GetROProperty("something") return s End Function...


Go Back   Geeks Talk > Software Testing > QTP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2008
Contributing Member
 
Join Date: Jun 2008
Posts: 55
Thanks: 3
Thanked 0 Times in 0 Posts
learqtptesting is on a distinguished road
how to return value from a function in QTP?

below is giving error: Please correct them

msgbox getSomething()

A return type must be declared?

Function getFlatRate()
s = browser("B").Page("p").WebElement("we").GetROProperty("something")
return s
End Function
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-17-2008
Junior Member
 
Join Date: Jul 2007
Location: CA
Posts: 16
Thanks: 2
Thanked 5 Times in 4 Posts
Fahed9090 is on a distinguished road
Re: how to return value from a function in QTP?

Hi try this,declair !
dim c
if c = window("flight reservation").winbutton("flight").getroproperty("flight") then
window("flight reservation").winbutton("flight").click
if c = c then
reporter.reportevent micpass,"flight button enabled ","clicked"
else
reporter.reportevent micfail,"flight button enabled","failed to clicked"
end if
end if

Last edited by Fahed9090 : 07-17-2008 at 05:46 PM.
Reply With Quote
The Following 2 Users Say Thank You to Fahed9090 For This Useful Post:
  #3 (permalink)  
Old 07-18-2008
Contributing Member
 
Join Date: Oct 2007
Posts: 30
Thanks: 0
Thanked 2 Times in 2 Posts
mgkganesh is on a distinguished road
Re: how to return value from a function in QTP?

Just assign the value to be passed outside to the function name as below. Also for multiple variable outputs from functions use Call by Reference method.

msgbox getFlatRate()

Function getFlatRate()
s = browser("B").Page("p").WebElement("we").GetROProperty("something")
getFlatRate= s
End Function
Reply With Quote
  #4 (permalink)  
Old 07-18-2008
Expert Member
 
Join Date: Jan 2007
Location: India
Posts: 171
Thanks: 3
Thanked 12 Times in 12 Posts
NawabShaikh is on a distinguished road
Thumbs up Re: how to return value from a function in QTP?

Quote:
Originally Posted by learqtptesting View Post
below is giving error: Please correct them

msgbox getSomething()

A return type must be declared?

Function getFlatRate()
s = browser("B").Page("p").WebElement("we").GetROProperty("something")
return s
End Function

msgbox getFlatRate()

Function getFlatRate()
s = "Test"
getFlatRate=s
End Function


Regards,
Nawab

Last edited by NawabShaikh : 07-18-2008 at 01:03 AM. Reason: Code Alteration
Reply With Quote
  #5 (permalink)  
Old 07-18-2008
Contributing Member
 
Join Date: Oct 2007
Posts: 30
Thanks: 0
Thanked 2 Times in 2 Posts
mgkganesh is on a distinguished road
Re: how to return value from a function in QTP?

dim s
call getFlatRate(s)
msgbox s

Function getFlatRate(s)
s = "Test"
End Function
Reply With Quote
Reply

  Geeks Talk > Software Testing > QTP


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Return Value of Functions janelyn C and C++ 3 09-24-2007 01:09 AM
Can void be the return value of main Function joel C and C++ 3 09-10-2007 01:21 AM
Can Functions Return more than 1 value Geek_Guest Oracle 2 07-20-2007 12:47 PM
The Return Of Kalayama! kalayama Get Together 3 01-14-2007 02:17 AM
What is the Return Value RajivPrasad ASP.NET 1 10-09-2006 03:17 PM


All times are GMT -4. The time now is 05:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved