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

Action1: I have a value "test" stored in a variable X. I want to use that variable X in Action2 .. how?

1 Answers  


Mention what are the different types of recording modes in qtp? Which will be used when?

0 Answers  


how and what kind of vb functions do us ein QTP?

2 Answers   Ordain Solutions,


What does VBS file contain...??? what is VBS file.. ???

6 Answers   GE,


What information do the columns in the Keyword View show for each step?

1 Answers  






Can we write winrunner language i.e TSL in QTP tool?

0 Answers  


How to use actions in qtp ?

0 Answers  


How to execute a WinRunner Script in QTP?

3 Answers   IBM,


i want to handle all the unwanted pop up through QTP i done that with recovery scenario but it need some title of pop up but i want that it should handle all the pop up even i don't give the title of that pop up in recovery scenario is there any general way to handle all the pop up please help

3 Answers  


how to use the regular expression for the below code-- swf("application name").swftreeview ("Treename").select"Medication;Pharmacy:56" There is a tree view window of the folder's ie Medication- >Pharmacy(sub folder)with 56 as count of records...The records can be different or if no records present in the specific folder..then it show "Paharmacy:-no records".Whe i record at the first time .....and try to rerun the same script with different records count say "pharmacy:800"..qtp is not regnizing it...therefore i want to user regular expression..but donot now how to use it and where to use...i have tried.... swf("application name").swftreeview ("Treename").select"Medication;Pharmacy:\*"..but it s of no use..plz help..me

0 Answers  


Can we use same virtual objects in many number of tests?

1 Answers   TCS,


What is Port testing. Whhen will you perform?

0 Answers  


Categories