## Pages

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

## Wednesday, June 24, 2009

### How to return multiple values from a function?

Usually Function procedure will return only one value. But by using arrays concept we can return multiple values from a function.
`'**********************************************************`
` `
`Function fnGetOddNumbersInRange(fStartRange,fEndRange)`
` `
`Dim oddNumbers()`
`Dim cnt,iCounter`
` `
`'Initiating a counter to redim the dynamic array`
`cnt=0`
` `
`For iCounter=fStartRange to fEndRange`
` `
`'Applying the odd number logic : num/2 <>0 then its an odd number`
`If iCounter mod 2<>0 Then`
`ReDim preserve oddNumbers(cnt)`
`' Storing Odd numbers in dynamic array`
`oddNumbers(cnt)=iCounter`
`cnt=cnt+1`
`End If`
` `
`Next`
`'Assigning array to the function`
`fnGetOddNumbersInRange=oddNumbers        `
` `
`End Function`
` `
`'**********************************************************`
` `
`'**********************************************************`
`'How to work with this function?`
` `
`'Here Function will return array value`
`oVal=fnGetOddNumbersInRange(1,10)`
` `
`For i=0 to ubound(oVal)`
`' Displaying the values in array`
`msgbox oVal(i)`
`Next `
`'**********************************************************`

#### 1 comment :

1. How to pass arguments to the following function if we will call it in a script?

function findflight(byval x)
with browser(home)
with .page(home)
.weblist(passengers).select x(1)
.weblist(from).select x(2)
.weblist(depmonth).select x(3)
.weblist(depday).select x(4)
.weblist(dest).select x(5)
.weblist(retmonth).select x(6)
.weblist(retday).select x(7)