How to return a value from function...?

you should not tell msgbox, print.. etc.,

Answers were Sorted based on User's Feedback



How to return a value from function...? you should not tell msgbox, print.. etc.,..

Answer / bfakruddin

in VB Script

Is This Answer Correct ?    3 Yes 1 No

How to return a value from function...? you should not tell msgbox, print.. etc.,..

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

How to return a value from function...? you should not tell msgbox, print.. etc.,..

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

How to return a value from function...? you should not tell msgbox, print.. etc.,..

Answer / siba sankar nayak

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

How to return a value from function...? you should not tell msgbox, print.. etc.,..

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

How to return a value from function...? you should not tell msgbox, print.. etc.,..

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

Post New Answer

More VB Script Interview Questions

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

6 Answers   Amazon,


How to access array data?

0 Answers  


wat is com(common object model)object for mozilla firefox??? if any knows the exact answer....plz rply me

2 Answers  


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

0 Answers  


Explain about scrrun.dll in vbscript?

0 Answers  






What are string functions in vbscript?

0 Answers  


Both Static and dynamic arrays are handled by VB script. Is it true?

0 Answers  


Write a program to create a Dynamic array of size 5 elements and display all the elements.

1 Answers  


how to validate the text in a web table

2 Answers   Mphasis,


write a vb script to display the size of the folder,date created and name of the folder

1 Answers  


PLz send me the VB scripts which is having more examples my email id : hareen_11@yahoo.com

0 Answers  


how to add the shared repository file to the script file while running the script manuall

2 Answers  


Categories