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 |
Write VB script to convert from feet to inches(hint 1feet=12 inches)
Why is the use of exit do or exit for statements within loops discouraged?
hi, How will write a regular expression of date in VB scripting.
How to Import data from a file (file is on the desktop) to the data table
write a program to display configuration of a local system with the help of vb script.
Mention what is the use of option explicit in vbscript?
Explain what is loose binding? Why is it not a good practice to use it?
What are the rules to name variable in vbscript?
What are keywords in the vbscript language?
How will you format a number in percetage format in vbscript?
what is the purpose of the Reporter.ReportEvent in QTP and also please give the brief description about Reporter.ReportEvent ?
What is the use of option explicit in vbscript?