Passing an array to API function 
Author Message
 Passing an array to API function

In previous version of VB you can declare a parameter of an API function
to be "As Any" in order to pass string or array or object. In VB.net,
"As Any" is not supported anymore. So how would you go about passing an
array?

I tried to declare the parameter to be "Byref ... As Object" and passed
the name of the array variable but doesn't work... And there's no VarPtr
in Vb.net either...

Thanks

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Sat, 15 Oct 2005 11:14:58 GMT  
 Passing an array to API function


Quote:
> In previous version of VB you can declare a parameter of an API function
> to be "As Any" in order to pass string or array or object. In VB.net,
> "As Any" is not supported anymore. So how would you go about passing an
> array?

> I tried to declare the parameter to be "Byref ... As Object" and passed
> the name of the array variable but doesn't work... And there's no VarPtr
> in Vb.net either...

> Thanks

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

What api are you trying to call?  If you want to pass say a byte array you
would do something like this:

Declare Function MyFunc Lib "myLib.dll" (ByVal ByteArray() As Byte) As
Integer

Dim ByteArray() As Byte = New Byte(10)
Dim myInt As Integer = MyFunc(ByteArray)

It would be much more helpfull though, if you would tell what API your
trying to call and what your trying to accomplish.  Many times, you don't
actually need the API call anyway :)

Tom Shelton



Sat, 15 Oct 2005 13:11:27 GMT  
 Passing an array to API function
(sorry for my late reply)

i was trying to get the listview column order using SendMessage api with
LVM_GETCOLUMNORDERARRAY, which takes a pointer to an integer array as
the lParam argument. but no matter how i declare the lParam parameter
(as object, as integer(), ...) VS.net either throws me some strange
exception even in the try catch block, or doesn't do anything...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Tue, 18 Oct 2005 17:50:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to Pass Array to a Function?

2. question on passing and returning arrays from functions

3. pass an array as function/sub argument

4. Question on passing array parameters to VB.NET Sub/Function

5. Passing of arrays to a function???

6. Passing arrays to a function

7. Passing arrays to functions

8. Passing Arrays to a Function in ASP (VBScript)

9. pass an array back from function

10. passing a control array to a function...

11. HELP: Passing an Array back in a function

12. Passing control array into global function - problem

 

 
Powered by phpBB® Forum Software