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 |
Hi, Anybody could you Please tell me How to write the script for Checking whether given number is Prime Number or not..Thanks in Advance
How to access array data?
wat is com(common object model)object for mozilla firefox??? if any knows the exact answer....plz rply me
hi i am trying for testing job for 3+ experience(fake) can u suggest me what type of projects i can keep in my resume and how much of knoeledge i should have abt that project.thnks in advance.urgt plz
Explain about scrrun.dll in vbscript?
What are string functions in vbscript?
Both Static and dynamic arrays are handled by VB script. Is it true?
Write a program to create a Dynamic array of size 5 elements and display all the elements.
how to validate the text in a web table
write a vb script to display the size of the folder,date created and name of the folder
PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com
how to add the shared repository file to the script file while running the script manuall