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 |
Plz give the vb script for the following scenerio. In travel booking we have to select from delhi to mumbai from the combobox The prices will be display in another combo box .But i have to select the lowest price for it and submit it
find the length of the string without using length function?
What is the purpose of regexp object in vbscript?
print the array values in ascending order?
what is the difference between modular and data and keyword driven framework
How to return a value from function...? you should not tell msgbox, print.. etc.,
compare the string without using stringcomp function?
Which function is used to perform string comparison?
How will you convert a string to lower case string using vbscript?
What is byref and byval parameters in vbscript?
Give examples where vb script can directly run on users system with windows as os?
How to scroll down a page while recording in qtp. suggest me any method apart from low level recording.