Is it possible to return multiple values from a function..?
Then how..?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
what is the difference between link and hyperlink?
Can any one tell me.......How the test engg's start testing in the compy environment.....real time tester PLSSSS help me i need in depth information regarding this...
What is active screen?
wt is memory leakage?
How to record object in runtime. I am testing one Image website in which every time image change on home page.so if i records the image list but during running image get change, and QTP gives error
how to display message with out using msgbox function?
What is the limitation to XML Checkpoints?
what is keyword driven testing
Give me detailed theritical explanation about keyword driven, hybrid framework, environment variables, hybrid frame work
When we use 'ERR' object to handle the exceptions in the script, do we need to include any statement in the beginning of the script..??
2 Answers DST Global Solutions,
While writing script using For Next Statement in QTP, I try defining the variable in Lib File I am getting syntax error whereas if I use the variable in script file, the script works fine. Can anyone help me in finding the reason behind this?. E:g Dim intStartRow (Define in Lib File----- say abc.vbs) Dim intRow (If I define this variable in Lib file I am getting Syntax error where as if I define in the script file ---- say xyz.mts the script works fine) IntStartRow=2 For intRow = intStartRow to xlWrksht.UsedRange.Rows.Count ‘Some Code here Next
How to Analyze the Checpoint results with Standard Checpoint ?