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

Write VB script to convert from feet to inches(hint 1feet=12 inches)

2 Answers  


Why is the use of exit do or exit for statements within loops discouraged?

0 Answers  


hi, How will write a regular expression of date in VB scripting.

1 Answers  


How to Import data from a file (file is on the desktop) to the data table

2 Answers   IBM,


write a program to display configuration of a local system with the help of vb script.

0 Answers  


Mention what is the use of option explicit in vbscript?

0 Answers  


Explain what is loose binding? Why is it not a good practice to use it?

0 Answers  


What are the rules to name variable in vbscript?

0 Answers  


What are keywords in the vbscript language?

0 Answers  


How will you format a number in percetage format in vbscript?

0 Answers  


what is the purpose of the Reporter.ReportEvent in QTP and also please give the brief description about Reporter.ReportEvent ?

4 Answers   CybAge,


What is the use of option explicit in vbscript?

0 Answers  


Categories