Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

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 Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2008
Expert Member
 
Join Date: Jun 2008
Posts: 212
Thanks: 6
Thanked 12 Times in 11 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 06: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: 208
Thanks: 3
Thanked 19 Times in 19 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 02: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

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


All times are GMT -4. The time now is 02:09 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved