Is it possible to return multiple values from a function..?
Then how..?

Answers were Sorted based on User's Feedback



Is it possible to return multiple values from a function..? Then how..?..

Answer / satish j

It is possible to return multiple values from a function?
Here I am taking the return values in an array and using
them as I want

mynum1 = 0
mynum2 = 0
dim linklist(2)
imax = ubound(linklist)

Function fncl1(ByRef mynum1,mynum2, x , y)
If i= 0 Then
z = "+"
Select Case z
case "+"
mynum1 = x +y
msgbox mynum1
fncl1 = mynum1
End select
else
z = "-"
Select Case z
case "-"
mynum2 = x- y
msgbox mynum2
fncl1 = mynum2
End Select
end if
End Function

For i=0 to imax
linklist(i) = fncl1(mynum1,mynum2,5,4)
If linklist(i) = mynum2 Then
Exit for
End If
Next

msgbox linklist(0)+linklist(1)
msgbox linklist(0)&","&linklist(1)

Is This Answer Correct ?    2 Yes 0 No

Is it possible to return multiple values from a function..? Then how..?..

Answer / rico

One way of getting mutiple values from function is by
passing values "ByRef" to the funtion and storing the
return values in the one or more arguemnts passed to the
functions.

Ex :
mysum = 0
msgbox mysum ' return 0
mysub = 0
msgbox mysub ' return 0

Function fnmul(byref mysum, mysub, x , y)

mysum = x + y
msgbox mysum 'return 9
mysub = x - y
msgbox mysub 'return 1

End Function

Call fnmul( mysum, mysub, 5, 4)

msgbox mysum 'return 9

msgbox mysub 'return 1

Is This Answer Correct ?    3 Yes 2 No

Is it possible to return multiple values from a function..? Then how..?..

Answer / rico

If we pass the parameters by "Byval" the last two msgbox
statement will return "0"

Ex :
mysum = 0
msgbox mysum ' return 0
mysub = 0
msgbox mysub ' return 0

Function fnmul(byval mysum, mysub, x , y)

mysum = x + y
msgbox mysum 'return 9
mysub = x - y
msgbox mysub 'return 1

End Function

Call fnmul( mysum, mysub, 5, 4)

msgbox mysum 'return 0

msgbox mysub 'return 0

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More QTP Interview Questions

Explain the concept of object repository and how qtp recognises objects?

0 Answers  


is qtp 9.2 create the scripts with the application run on mozilla firefox browser?

3 Answers  


Hi all. Could anyone tell me the difference between an Action and a Function in QTP. Thanks in advance and Merry Christmas.

3 Answers   IBM,


what is meant by iterative model?What is its working principle?What are its advantages and what are its drawbacks?

2 Answers  


how can i call an external action,which is not added external action of an action?

2 Answers   Ordain Solutions,


how many test scripts we will write in qtp? very urgent. please??? Thanks in advance..

1 Answers   Mind Tree,


Hai Guys, can anybody show me how to write automaed test cases using VB scprit(examples)...i had an interviw soon...please guyz send as quickly as possible

5 Answers  


What are the advantages of QTP over WinRunner?

5 Answers   CTS,


How can we disable popup blocker? (I think it means when we get a pop up messge(its error) how we wil disable that one with out interrupting normal process)

5 Answers  


How will u find that how many List boxes( and check boxes) are present in one particular window

8 Answers  


Using Regular expression method some particular value is not present in given value. HOow do use regular expression? Forexample password all number,character ,special character are accepted but (_',)underscore,comma are not used. How do write regular expression.

1 Answers  


explain abt dyanamic changing object with example?

0 Answers   Wipro,


Categories