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 |
Could Anybody Please tell me What is the script for Find 3rd Largest element in the Array without using a SORT function int Find(int arr[], int size); Thanks in Advance..
how to check whether link is disabled in QTP??
hi all, i had a question, that how to find out hiding a coloumn in a table i had a table having the following column names NAME DESCRIPTION CREATED TIME CREATED USER if i right clicked on a NAME column it will displays a menu having the same column names in a list like NAME DESCRIPTION CREATED TIME CREATED USER with check boxes.if i unched any check box, that column name should not be appear in the main table column names could anyone please solve this problem?
Hello All, In QTP 9.2 for Mozilla Firefox, there is webelement in my application, I tried to click on that using decsriptive programming, but it does not work. and for this i tried this code too: Set obj = CreateObject ("Mercury.DeviceReplay") absx = Browser("").Page("").WebElement(".").GetROProperty ("abs_x") absy = Browser("").Page("").WebElement(".").GetROProperty ("abs_y") obj.MouseMove absx, absy obj.MouseClick absx, absy, 0 But it is not clicked. Can anyone help me out for this problem. Thnx in Advance
write a vbscrpit to swap values
What is difference between vbscript and vba?
Why is error handling required?
Which constant is used for print and display functions and works as same as pressing enter key?
What are the naming conventions while declaring a variable in the vbscript language?
What are class variables?
How can you destroy an object in vbscript?
i created script for login in QTP,i parametirized that using global sheet,problem i am facing is first i want to login with first values provided in excelsheet and want to perform some operation,second time if call same action it should login with second values in excelsheet