Results 1 to 8 of 8

Thread: can we have data types for C structs and union in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    4

    can we have data types for C structs and union in VB

    Hi

    I am having this structure in VC, can I have the same data type in VB, and how it will look like

    Thanks

    struct trevariant_struct {
    short NullInd;
    Long TreType;
    union trevariant_datatype {
    long VLong;
    double VDouble;
    char *VString;
    TRE_BLOBVALUE VBlob;
    struct trearray_struct {
    long Size; /* Size of array */
    TRE_VARIANT *Elements; /* Array of elements */
    } VArray;
    struct trehash_struct { /* All TRE_HASH types */
    long Size; /* Number of values in hash */
    TRE_HASHVALUE *Elements; /* Array of key value pairs in hash */
    } VHash;
    } Data;
    };
    Last edited by vipingverma; Jun 28th, 2004 at 07:18 AM.

  2. #2
    Lively Member
    Join Date
    Jun 2004
    Location
    Dubai, UAE
    Posts
    64
    Hi

    You can use a Type declaration as a part of struct. Like...

    Type <TypeName>

    Members Declaration
    Members Declaration
    Members Declaration
    -------
    End Type

    There's no concept of Unions in VB.


    Gs

  3. #3
    Banned DiGiTalErRoR's Avatar
    Join Date
    Sep 2002
    Posts
    68
    VB Code:
    1. Private Type tVals
    2.   Val as Long
    3.   Loc as POINTAPI
    4. End Type
    5.  
    6. Private Type tSys
    7.   strName$  
    8.   Vals() as tVals 'dynamic UDT array
    9. End Type

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    4
    Thanks for the response, so that means we cant map this data structure in VB ?

    VB Code:
    1. struct trevariant_struct {
    2.  short NullInd;
    3.  Long TreType;
    4.  union trevariant_datatype {
    5.                                        long VLong;
    6.                                        double VDouble;
    7.                                        char *VString;
    8.                                        TRE_BLOBVALUE VBlob;
    9.                                         } Data;
    10. };

  5. #5
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    I used the VB Type but I wasn't able to pass it around the whole project for some reason. Instead I just made a class.

    This is 2004 - forget structs - use a class

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Originally posted by Dave Sell
    I used the VB Type but I wasn't able to pass it around the whole project for some reason ...
    If you did not declare it as Public at the MODULE level then you obviously won't be able to ...

  7. #7
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    Yes it was Public - it just wouldnt pass around to all parts of the code when Passing as an argument ByVal.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    4

    Parallel of C struct?Union in VB

    Hi

    I am not getting the meaning of replies, I have a dll for which source code is not available to me and it expects a struct as parameter which internally has union inside ( Data structure I have already posted), now is in VB is there any way to create a data structure like this C structure
    Last edited by vipingverma; Jul 1st, 2004 at 10:34 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width