|
-
Nov 7th, 2000, 10:28 PM
#1
Thread Starter
New Member
Hi all,
Any idea on how to convert this c++ function header to vb declaration ?
UINT CmdDownLoadIULabel(myStructures theArray[500]);
I am more concerned on how I am to declare the Array part (theArray[500]).
Thanks
-
Nov 9th, 2000, 07:49 AM
#2
Member
It should be enough to pass the first entries addres.
Declare Function CmdDownLoadIULabel Lib "..." (ByVal myStructures as Any)as integer
ret = CmdDownLoadIULabel (myStructure(1))
you need to make sure the procedure knows how many entries are in the array.
-
Nov 9th, 2000, 03:19 PM
#3
Fanatic Member
Hmm, let's take a closer look.
UINT CmdDownLoadIULabel(myStructures theArray[500]);
UINT means that the return value is an unsigned integer. In VB you have to use a Long, since bit 15 can't be 1 in an Integer.
CmdDownLoadIULabel is the name of the function. No problem.
The parameter theArray[500] is an array with 500 elements [0..499] of a type called myStructures and has to be defined with the Type statement in VB.
I should redeclare this function in VB like:
Code:
Function CmdDownLoadIULabel (theArray() As myStructures) As Long
But VB gives me an error when using the user-defined type myStructures. By now, I don't know how to pass a user-defined type to a function.
I'll keep in touch...
-
Nov 9th, 2000, 03:30 PM
#4
Fanatic Member
Here we are again...
If you want to pass a user-defined type to a function, then this function has to be declared as Private, otherwise you get an error (like I did)!
So, here's the solution:
Code:
'In a form...
Option Explicit
Private Type myStructures
a As Integer
b As Byte
c() As Long
'...
End Type
Dim theArray(500) As myStructures
Private Sub Form_Load()
CmdDownLoadIULabel theArray
End Sub
Private Function CmdDownLoadIULabel (ByRef theArray() As myStructures) As Long
Debug.Print UBound(theArray) 'Should also be 500!!!
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|