Hello friends... this is the question oftenly asked in Interviews...
Returning a multiple values with function....
Function calc(a,b,c,d) ' Called Function  Function Definition
msgbox "a is value "&a ' a value passed from calling function
msgbox "b is value "&b ' b value passed from calling function
c=a+b ' Calculation of c
d=ab ' Calculation of d
calc=array(c,d) ' Assigning Calculated values in array of Function name (calc here)
End Function
res=calc(10,20,c,d) 'Calling Function with Passing input parameters
msgbox res(0) ' returning a value from array of Function (calc here)
' User Inputs to perform Addition and Subtration and returning both the values by using Functions... (returning two values by using single name of Function)
Function calc(a,b,c,d)
msgbox "Value of a is "&a
msgbox "Value of b is "&b
c=cint(a)+cint(b)
d=cint(a)cint(b)
calc=array(c,d)
End Function
a=inputbox("Enter a value:","a Value",10)
b=inputbox("Enter b value:","b Value",20)
result=calc(a,b,c,d)
msgbox "No. of Values in Array is :"&ubound(result)+1
iter=ubound(result)
For i= 0 to iter
msgbox "Returned Value of "&i+1&"th iteration is "&result(i),3,"Returned Value of Function"
Next
Thanks & Regards
Baba Fakruddin.D
This is Baba, very much passionate about Automation Testing and Tools. I'm working as a consultant and I have worked on Manual and Automation Testing using QTP/UFT, QC/ALM, RFT and Selenium on different applications & projects. So far, I have designed different types of frameworks and now I would like to share my thoughts, experiences, challenges faced so far with all. Here, I'll be posting interview questions, any new inventions, updated versions and their differences... etc.,
Subscribe to:
Post Comments (Atom)
QTP / Software Testing Blog's



Does QTP support Netscape?4 years ago




No comments:
Post a Comment