Passing String Arrays between VB and VC 
Author Message
 Passing String Arrays between VB and VC

  Does anyone know anthing about how to make a VC++ DLL that uses
variable length string arrays passed from VB 4.0?  I know how to make
one
that accesses other arrays and variable length strings but NOT arrays
of variable length strings.  I would also like info on BYTE array
conversion and finding an LBOUND and UBOUND function in C++ that works
on VB arrays.
                                            Thanks,
                                            Cedric Johnson



Sat, 21 Nov 1998 03:00:00 GMT  
 Passing String Arrays between VB and VC

Quote:

>  Does anyone know anthing about how to make a VC++ DLL that uses
>variable length string arrays passed from VB 4.0?  I know how to make
>one
>that accesses other arrays and variable length strings but NOT arrays
>of variable length strings.  I would also like info on BYTE array
>conversion and finding an LBOUND and UBOUND function in C++ that works
>on VB arrays.
>                                            Thanks,
>                                            Cedric Johnson


You should pass your arrays as Variants to C++.  Then use the 'parray'
member of the tagVariant structure (see help file on "VARIANT and
VARIANTARG").  It is a SAFEARRAY FAR* which you need to pass to all the
SafeArrayXxxx functions in C++.

For checking the bounds use:
----------------------------
SafeArrayGetUBound
SafeArrayGetLBound

To access and unaccess the data use:
------------------------------------
SafeArrayAccessData
SafeArrayUnaccessData

It's very important that you "unaccess" the data or your array will be
locked and you will be unable to ReDim it or delete it in VB.  This will
cause major problems when your VB application tries to free that memory
(namely - it can't and so it locks up).

Geoff
-----------------------
"I brake for MCSD's..."
-----------------------



Sun, 22 Nov 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing String Arrays between VB and VC

2. passing vb5 arrays of strings to a vc++ 5 C dll

3. Passing VB array to VC

4. Passing strings between VC and VB

5. passing arrays from vb to vc

6. VC & VB String Array for CDO Categories

7. passing array to VC server

8. passing (string) arrays from VB to C-DLL and vice versa

9. Passing an array of strings from VB to Windows API

10. Passing array of strings to a dll in VB

11. Passing an array of Strings to VB via ActiveX

12. Passing VB String array to DLL???

 

 
Powered by phpBB® Forum Software