GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Testing Tools  >  QTP
Go To First  |  Previous Question  |  Next Question 
 QTP  |  Question 205 of 666    Print  
How can we return values from userdefined function? anybody provide code with small example its great for me.

  
Total Answers and Comments: 2 Last Update: June 06, 2008     Asked by: Magadala 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 15, 2006 02:30:04   #1  
seleena        

RE: How can we return values from userdefined function...

The syntax of a Function:

[Public [Default] | Private] Function name [(arglist)]   [statements]   [name = expression]   [Exit Function]    [statements]   [name = expression]End Function 

Arguments

Public
Indicates that the Function procedure is accessible to all other procedures in all scripts.
Default
Used only with the Public keyword in a Class block to indicate that the Function procedure is the default method for the class. An error occurs if more than one Default procedure is specified in a class.
Private
Indicates that the Function procedure is accessible only to other procedures in the script where it is declared or if the function is a member of a class, and that the Function procedure is accessible only to other procedures in that class.
name
Name of the Function; follows standard variable naming conventions.
arglist
List of variables representing arguments that are passed to the Function procedure when it is called. Commas separate multiple variables.
statements
Any group of statements to be executed within the body of the Function procedure.
expression
Return value of the Function.

Note: So, to return a value, assign the return value to the function name.

For Eg:

Function BinarySearch(. . .)
      . . .
      ' Value not found. Return a value of False.
      If lower > upper Then
            BinarySearch = False   
            Exit Function
      End If
      . . .
End Function


 
Is this answer useful? Yes | No
June 06, 2008 01:22:42   #2  
akothuru Member Since: April 2008   Contribution: 21    

RE: How can we return values from userdefined function? anybody provide code with small example its great for me.

Function can return only one value
To return value, use the following syntax

E.g.
Function FunctionName()
     FunctionName= True
End Function


FunctionName = True 'Boolean value
or
FunctionName = "Abcd" 'String
or
FunctionName = var_i 'variable

If you want to return multiple values, you should use ByRef peremeters. By Default, the function parameter type is ByVal. The parameters declared as ByRef can only send back the values to script which are updated inside function 
a =4
b =5
msgbox "a: " & a 'diaplay 4
msgbox "b: " & b 'diaplay 5
Call abcd(a,b)
msgbox "a: " & a 'diaplay 5
msgbox "b: " & b 'diaplay 4
  
Function abcd(ByRef a, ByRef b)
   temp = a
   a = b
   b = temp
   abcd = True
End Function






 
Is this answer useful? Yes | No

 Related Questions

Answer posted by shreethik on 2005-06-09 08:36:38: Output values enable to view the values that the application talkes during run time.When paramaterised, the values change for each iteration.Thus by creating 
Latest Answer : Output value is used for capturing value dynamically to the datatable ...

Latest Answer : For per action repository .mtrfor shared repository .tsrfor cod file .vbs ...

View Question | Asked by : Rahu Rathan

If you have the same application screen with 7 drop down boxes and approximately 70 values how do you test with QTP?
Read Answers (2) | Asked by : damo

Latest Answer : Actually, there will be 3 types functions : --> Local script (Function definition and function call will be in script only ) --> Built functions (Predefined functions , only we have to call these functions) --> Library functions ...
Read Answers (9) | Asked by : kumar

These are the new features which are available in QTP8.2 and which are not present in 6.5 version.Keyword View: Lets you easily build and maintain tests without writingVBScripts.Auto-Documentation: Provides 
Latest Answer : Really great help,Thanks ...
Read Answers (2) | Asked by : James

How do u ignore exceptions raised by a procedure or function within a package.Ex: Package a { Proc1; Func1; ---- raised an exception Proc2; Proc3; }Note : Even if Func1 raises an exception proc2 and proc3 must be excecuted.
Read Answers (1) | Asked by : Uday Sharma

Give an example of a regular expression,user-defined function and built-in-function?how to make a user-defined function reusable?
Read Answers (2) | Asked by : Mann

Latest Answer : Built-in-functions:dim myleftnamemyleftname = "Vinothkumar"msgbox left(myleftname,6)External Functions ;This requires the user to add the library in the Test >> settings >> Resources and call this libex: mylib.vbsfunction hi()dim myleftnamemyleftname ...
Read Answers (1) | Asked by : Mann

How to add a failure from a VBscript function to the results. how can I implement the functionality of checkpoint functionality from by VBScript. For Ex: I want to record a failure if some calculations evaluate to false.
Read Answers (2) | Asked by : Ashok


 Sponsored Links

 
Related Articles

SQA Software and Tools

SQA Software and Tools In quality assurance it is always important to get all the help we could get In other industries developers could easily check the products manually and discard those that do not meet the standard The length and the width of the product are checked to maintain standardization
 

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

code

geshibot lang javascript" head This is a JS snippet from Geshi Bot" Replaces the geshi default classes with mambo joomla classes function replaceGeshiWithMamboClasses if document document getElementsByTagName Category
 

Business Network Virtual Communication Tools

Business Network Virtual Communication Tools Since ages the Business community heavily relied on face to face communication for building Business relationships Face to face communications formed the basis for trust in a relationship An individual’ s appearance or the physical appearance of
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

C++ Function Passing Types

C Function Passing Types In this C tutorial you will learn about function passing types two types of arguments passing in functions passed by value  and  passed by reference are discussed here mosgoogle center The arguments passed to a function can be performed in two ways Passed
 

What are Data Access Tools

Data access is the process of entering a database to store or retrieve data. Data Access Tools are end user oriented tools that allow users to build structured query language (SQL) queries by pointing and clicking on the list of table and fields in the data warehouse. Thorough computing history, t
 

What is DECODE function used for?

DECODE is used to decode a CHAR or VARCHAR2 or NUMBER into any of several different character strings or numbers based on value. That is DECODE does a value-by-value substitution. For every value that is given in the DECODE function it makes an if then check and matches the value. The general format
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape