How many ways return more then one value from function?

Answer Posted / kurubaharibabu

Dear All,
I have updated all three ways the below code..



Function func1(a,b)
Dim c(3)
c(0)=a+b
c(1)=a-b
c(2)=a*b
func1=c
End Function
x=func1(2,3)
For i=0 to ubound(x)-1
msgbox x(i)
Next
'=====================================================
Function func2()
Dim c
c=array("har","babu")
func2=c
End Function
x=func2()
msgbox x(0)
msgbox x(1)
'===========================================================
Function func3()
Set dic=createobject("Scripting.Dictionary")
dic.Add "a","apple"
dic.Add"b","bal"
dic.Add"c","cat"
Set func3=dic
End Function
Set x=func3
msgbox x.Item("a")
msgbox x.Item("b")
msgbox x.Item("c")
'============================================================
Class user
Public var
Public cat
End Class
Function func4()
Set obj=new user
obj.var="hari"
obj.cat=123
Set func4=obj
End Function
Set x=func4()
msgbox x.var
msgbox x.cat
'===================================================================

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I have two For loop, first For loop does is creates a customer and input the customer info and then the second for loop within the first for loop does the follows which is capture the customer name and verify the with the data within the datatable. The problem I am coming across is that when it goes through the second time creating another customer and then verify the second customer then it creates the following during runtime. I want is to have the customer2 below Customer1 under the Customer_from_Apps. Any help will be greatly appreciate it. Customer Customer_from_Apps Customer_from_Apps1 Customer1 Customer 1 Customer2 Customer2 Window("Customer Desktop").Window("Customer Tracking (Privacy").WinObject("TreeView20WndClass").Click 92,244 runtimevalue = .VbTreeView("vbname:=AppServerTree").GetROProperty("Selectio n") Customer_Val= Datatable.GlobalSheet.AddParameter ("Customer_from_Apps",runtimevalue) row=datatable.getsheet("Global").GetRowCount For x=1 to row datatable.SetCurrentRow(x) Data_Val=Datatable.Value("Customer",dtGlobalSheet) If (trim(Customer_Val)=trim(Data_Val)) Then Reporter.ReportEvent micPass, "Customer validation successful", "Actual Value: " &Data_Val&vbcrlf& "Customer Value: " &Customer_Val else Reporter.ReportEvent micFail, "Cusotmer validation unsuccessful", "Actual Value: " &Data_Val&vbcrlf& "Customer Value: " &Customer_Val End If Next

1324


What is the Difference between copy to action and call to action?

574


What is object repository in qtp?

551


Which scripting language used by quicktest professional (qtp)?

656


What are the two types of repositories available, explain them?

580






How to use transactions in qtp?

551


How to read a text file from QC using QTP. I would like to do something like this. But instead read a file from QC and NOT from my local drive. Set fso = CreateObject("Scripting.FileSystemObject") Set InputFile = fso.OpenTextFile("C:\test.txt", ForReading) Thanks

2743


What is the file extension of the code file and object repository file in QTP?

585


How to check which add-ins are associated with a test in qtp?

573


how do you parameterize search button from the website? the page is a single winobject and i have made a virtual object button of search button but search box can't be converted into a winedit and if we try to convert it into winedit the value we enter in a searchbox appears as numbers in the script so we arent able to parameterize.help!!!

1720


How to make qtp understand the difference amongst the same type of objects .suppose there are 5 check boxes in a page and I have to choose the 2nd one, how to do that through script?

556


How you can make an action as re-usable action?

639


can any body clearly explain about keyword driven framework .give me the explanation for files what ever you use in this frame work?

1676


How would you export a script from one pc to another in qtp?

649


How reliable are the site's Internet connections required to be? And how does that affect backup system or redundant connection requirements and testing?

689