azsoft
asked on
c declaration in vb - (structure)
how to declare the following c structure in vb
typedef struct tagVBPARAM
{
UINT nParam;
ULONG nStatus;
}
VBPARAM;
typedef struct tagVBPARAM
{
UINT nParam;
ULONG nStatus;
}
VBPARAM;
Tim, I think UINT is 32 bit and ULONG is 64 bit. I was thinking it would be:
Type tagVBPARAM
nParam As Long
nStatus As Double
End Type
But there are definitely problems reading the binary unsigned integer from a floating point var.
Type tagVBPARAM
nParam As Long
nStatus As Double
End Type
But there are definitely problems reading the binary unsigned integer from a floating point var.
ASKER
what happen to the VBPARAM on the last line.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>The C++ structure you show has 2 names, tagVBPARAM and VBPARAM.
More that there is a declared instance of the structure. In VB:
Dim VBPARAM as tagVBPARAM
More that there is a declared instance of the structure. In VB:
Dim VBPARAM as tagVBPARAM
I am with Paul.
Cheers
Cheers
The C++ structure has 2 different names. The VBPARAM is not a variable of type tagVBPARAM, it is the type tagVBPARAM.
If you had the exact c declaration in VB, you would be able to do the following with exactly the same results.
DIM t1 as tabVBPARAM
DIM t2 as VBPARAM
VB doesn't support assigning multiple type names to the same data type and I have never found a place where doing it in C is benefitial. To have the exact same thing in VB you would do the following, but my first post should be all you need.
-------------------------- ---------- ----------
Type VBPARAM
nParam as Long
sStatus as Long
End Type
Type tagVBPARAM
nParam as Long
sStatus as Long
End Type
-------------------------- ---------- ----------
Notice that the type is declared twice, once for each name that the C declaration used.
If you had the exact c declaration in VB, you would be able to do the following with exactly the same results.
DIM t1 as tabVBPARAM
DIM t2 as VBPARAM
VB doesn't support assigning multiple type names to the same data type and I have never found a place where doing it in C is benefitial. To have the exact same thing in VB you would do the following, but my first post should be all you need.
--------------------------
Type VBPARAM
nParam as Long
sStatus as Long
End Type
Type tagVBPARAM
nParam as Long
sStatus as Long
End Type
--------------------------
Notice that the type is declared twice, once for each name that the C declaration used.
Ah you're right JoeBob. I confused typedef with a simple struct definition. Mebad.
How is that a "B" answer? I gave you exactly what you asked for plus a little extra info. You can copy and paste my answer into your VB app and it will work.
ASKER
Joebob, thank you very much. I wish i could change the score to A.
nParam As Integer
nStatus As Long
End Type