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

Hi, actually I completed Btech(CS). But i Will go to admin (Facility) interview. So, If Interviewer asking like " Why You choose this field". What we say? pLZ PLZ PLZ PLZ >............................................Send me.....

2 Answers  


Ehat is the descriptive programing in QTP?

4 Answers  


how to count spaces in a given string ex: "this is jagadeesh" in QTP with simple functional script

5 Answers   Cap Gemini,


I want to do QTP Certification what is the pattern of Question paper.

0 Answers  


what the diffference between test data and test cases what is meant by object hierarchy in qtp

4 Answers   Virtusa,






What are the types of environment variables in qtp?

0 Answers  


how to handle the textboxes where in it should take the sum like ex:: while posting a question in this site it will for what is the result of 6+3=__ where in we have to enter manually 9 and click on submit... but how to handle these cases in qtp.. can someone plz help me out wid dis...

1 Answers  


Inserting a Call to Action is not importing all columns in Datatable of globalsheet. Why?

1 Answers   Crea,


How to map the test cases to requirements in QC?

4 Answers   IBM,


HOW AUTOMATE TEST SCRIPT ? what time it will do? after gneration of basic script or Any , Plz explain detailed?

0 Answers   Wipro,


If you have given 1000 manual test scripts, what test you will do? and how?

2 Answers  


What is Cross browser testing? Does UFT support it?

0 Answers  


Categories