How to return a value from function...?
you should not tell msgbox, print.. etc.,
Answers were Sorted based on User's Feedback
Answer / vgr
Dim StrFunVal
StrFunVal = fn_MyFunction(7)
Function fn_MyFunction(Num)
fn_MyFunction=Num+8
End Function
During the execution the "StrFunVal" variable will contain
the value 15. If you don't want to use 'Msgbox' or 'Print'
then declaring a variable is prefered.
For your other question I haven't come across returning
more than 1 value from functions. Probably we have to use a
ARRAY kind of stuff...but not sure. Need to work on it.
Cheers,
VGR
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / rishi agrawal
Function MyFunction(Num)
InputBox("What is your name?","My Input")
'Code for return value from function
MyFunction= Num + 1
End Function
| Is This Answer Correct ? | 3 Yes | 2 No |
In which language?
In C. C++, Java like language,
we can use "return" key word to returnd values from
functions.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / bfakruddin
Function MyFunction(Num)
MyFunction=Num+1
End Function
Num=InputBox("Enter a Number")
call MyFunction(Num)
msgbox MyFunction 'It returns Num+1 value calculated in
Function
Just we have to use the Function Name to return a value...
and we can use that value out of that function...
One more question Can we return more than 1 value from
functions?
visit for qtp info http://qtptesters.wordpress.com
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / selva
yes function can return multiple vales.
Public Function fn()
Dim arr(1)
arr(0)=23
arr(1)=67
fn=arr
End Function
a=fn
| Is This Answer Correct ? | 0 Yes | 0 No |
Diff between web table ,datatable and data base (QTP)
if there is any string in a given format like as "company name employeecode date" then we have to fetch employeecode form string for ex-string is "capgemini12345june2013" then we have to fetch 12345 by using vb script so guys how can we do that please reply it.
How to take whole text output from screen of Bitmap Application.
Hi, can any one tell this Actually I AM NEW TO QTP I have one qtp script in which it calls the vbs file during it's run TIME by using the ExecuteFile "absolute path" If the vbs file is executed seperately it will give the output in a msgbox In the same way if qtp script is executed the result will be displayed in w result window right? Now the question is how to get that vbs file output in the qtp result window when I run the qtp script which calls the vbsfile during it's run TIME
How to return only alpha bate string from an string str = "bibhu@#$%&das&*)(SUndar"
a;;b;c;;;d in this string output is abcd will come how can we do that in vbscript in QTP testing?
There are 5 web pages.write a script to click the button on 4th web page.
how do you make the variable declaration mandatory?what is the use of "option explicit"?
I am running a windows based application.While running the script on QTP ,The Application pop-up an Error Message as "object Disabled" in two different scenarios Scenario 1-->The Application pop-up up a Message for Max Session Reached(as the application is set to hold 2 session and if if crosses the pre-defined limit then the error message pop-up) Scenario 2-->When Network connectivity is disabled the Application screen gets greyed out in colour with no operation possible. Now through Exception handling features in QTP ,we need to do the following For Scenarion 1-->Through Exception handling we need to just accept the Message pop-up in the Application and and resume with the call function as is for Scenario 2--> Through Exception Handling featutes on QTP we need to shut down the client , restart the client and resume the call functions as it is Note: The Application returns an Error Message as "object disabled" in both the cases i.e for pop-up message and when the Apllication getting greyed out due to Network failure how can we enhance the script in such a way that for the same error message retured by the application in two different and how to handle them????
write a text script to display * as below ********** **** **** *** *** ** ** * * * * ** ** *** *** **** **** **********
When are redim statement and preserve keyword used in the vbscript language?
Explain about vb script?