HELP: Passing an Array back in a function 
Author Message
 HELP: Passing an Array back in a function

Hi

I am writing an ActiveX.dll in VB6. It has a GetCustomer() function
which connects to a database and gets the names of customers. The
GetCustomer() function stores the names in an array. I want to pass that
array back to the calling procedure. Can anyone tell me how?


Thanks

Michael Hamilton



Wed, 27 Feb 2002 03:00:00 GMT  
 HELP: Passing an Array back in a function
Why not just either make the Recordset Public, or create methods to access
the recordset.  This saves transferring existing data to another data type
(taking up time and resource) and also you could have problems with having
to re-size the array.  Yes I know you can re-dim it but why go to all the
hassle?


Quote:
> Hi

> I am writing an ActiveX.dll in VB6. It has a GetCustomer() function
> which connects to a database and gets the names of customers. The
> GetCustomer() function stores the names in an array. I want to pass that
> array back to the calling procedure. Can anyone tell me how?


> Thanks

> Michael Hamilton



Wed, 27 Feb 2002 03:00:00 GMT  
 HELP: Passing an Array back in a function

Quote:
> Hi

> I am writing an ActiveX.dll in VB6. It has a GetCustomer() function
> which connects to a database and gets the names of customers. The
> GetCustomer() function stores the names in an array. I want to pass that
> array back to the calling procedure. Can anyone tell me how?

Have you tried passing the array by reference?  I'm not sure this will work,
but it's worth a shot.

Cheers,

-Dan Abbott



Wed, 27 Feb 2002 03:00:00 GMT  
 HELP: Passing an Array back in a function
Michael -

I would have to know more of what you need to solve, before I would
say that this is a good technique in your situation; I do not want to
know, though :)

In VB 6 only:

Private Sub WhatAreTheCustomers()

    Dim aCustomer() As String
        'get a strong typed array from a pub. function
    aCustomer = GetCustomer()

End Sub

Public Function GetCustomer() As String()

    Dim a(0) As String
        'get the customers, I am guessing via ADOR
    a(0) = "Joe Good Customer"
    GetCustomer = a

End Function

With previous versions of VB, you will have to declare both the Arrays
and return as Variant.  Have you considered properties of a class with
private variables for this?, which could lesson the overhead and
redundant cycling through the data.  Also, ADO will return arrays out
of recordsets with GetRows(), if you are thinking about iterating the
records yourself.  This may save lots of code and debug.

HTH,

- Charlie

Charles Ferebee, MCSD MCSE MCP+I MCT
Sr. Web Developer
Toysmart.com - Click on Your Child's Potential

On Sat, 11 Sep 1999 17:56:37 +0100, Michael Hamilton

Quote:

>Hi

>I am writing an ActiveX.dll in VB6. It has a GetCustomer() function
>which connects to a database and gets the names of customers. The
>GetCustomer() function stores the names in an array. I want to pass that
>array back to the calling procedure. Can anyone tell me how?


>Thanks

>Michael Hamilton



Thu, 28 Feb 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP: Using an Array passed back from a function

2. pass an array back from function

3. Passing array back from Sub/Function

4. Passing Array to Session Variable Then back to Array

5. Need Help on Passing Array into Function

6. Passing a variant array from asp to a cls and back

7. VB5: Passing Arrays to a DLL and back

8. Passing array from ASP (VBScript) to DLL and back

9. Passing arrays back and forth from COM

10. Passing an array back from a class

11. how to get value passed back from function..

12. Passing recordset back from function

 

 
Powered by phpBB® Forum Software