Results 1 to 11 of 11

Thread: C++ to VB.NET conversion.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2008
    Posts
    204

    C++ to VB.NET conversion.

    Hi All,
    I am trying to interface a third party DLL to my VB.NET program. I am stuck in converting the following code to VB.NET. Hence it would be very helpful if anybody could post equivalent code in VB.NET for the C++ code posted below:

    Code:
    typedef struct __attribute__((__packed__)) __tagRAD_CTRL_BITS {
    	uint16_t tr_bFrameRateIndex :3; 
    	uint16_t tr_bAECExposure :1;    
    	uint16_t tr_bRadExposure :1;   
    	uint16_t tr_bFilamentSelect :3;
    	uint16_t tr_bFieldSelect :3;    
    	uint16_t tr_bFilmScreen :2;    
    	uint16_t tr_bAECDensity :3;    
    } TR_RAD_CTRL_BITS, *PTR_RAD_CTRL_BITS;
    
    
    typedef struct __attribute__((__packed__)) __tagRAD_EXAM_DATA_STR {
    	uint8_t tr_nkV_Hi_Byte;
    	uint8_t tr_nkV_Lo_Byte;
    	uint8_t tr_nmA;        
    	uint8_t tr_nBUT;     
    	uint8_t tr_nBUmAs;      
    	TR_RAD_CTRL_BITS tr_trRadCtrlBits; 
    	uint8_t tr_nRunLength; 
    } TR_RAD_EXAM_DATA_STR, *PTR_RAD_EXAM_DATA_STR;
    
    
    typedef union __attribute__((__packed__)) __tagRAD_EXAM_DATA {
    	TR_RAD_EXAM_DATA_STR u_trRadExamData;
    	uint8_t u_naRadExamData[8];        
    } U_RAD_EXAM_DATA, *PU_RAD_EXAM_DATA;
    Regards,
    Susheelss

  2. #2
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,248

    Re: C++ to VB.NET conversion.

    I always add to the reputation of those whose post are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2008
    Posts
    204

    Re: C++ to VB.NET conversion.

    Thanks Mr.Dolot. But the solution provided by converter is not working.

    Regards,
    Susheelss

    Quote Originally Posted by dolot View Post

  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    677

    Re: C++ to VB.NET conversion.

    Bit fields (in your first type) are simply not available in VB.
    In modern programming there is little need for this.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  5. #5
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by dolot View Post
    I doubt those things actually work. I always thought they were just scams.

  6. #6
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by Toph View Post
    I doubt those things actually work. I always thought they were just scams.
    Yes they do work, and not a scam.

    There are some online solutions for small snippets of code, you can use Reflector to 'convert' assemblies from one language to another, or you can use a full-blown solution, like this, to perform a conversion for you; this usually accommodates most of the quirks when converting from one language to another.
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  7. #7
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by SJWhiteley View Post
    Yes they do work, and not a scam.

    There are some online solutions for small snippets of code, you can use Reflector to 'convert' assemblies from one language to another, or you can use a full-blown solution, like this, to perform a conversion for you; this usually accommodates most of the quirks when converting from one language to another.
    I still doubt it.
    Look.


    They're charging for VB.NET and C# conversions, when you can do it for free using http://converter.telerik.com/

    Tell me that's not a scam.

  8. #8
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by Toph View Post
    I still doubt it.
    Look.


    They're charging for VB.NET and C# conversions, when you can do it for free using http://converter.telerik.com/

    Tell me that's not a scam.
    Interesting logic. Any software that is sold is a scam if a reduced feature version is freely available? By that reasoning, I guess the paid versions of Visual Studio are a scam because a large percentage of their features are offered in the free Express Editions. Also by that analogy, any professional programmer giving free advise on this forum is a scammer because they may also charge for their services.

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,235

    Re: C++ to VB.NET conversion.

    Those structures are nothing more than a UInt16 and a Byte (UInt8 would be a Byte). The fact that the bits within the UInt16 have some kind of meaning may not be relevant. How are they used? If the dll just needs the arguments, then you might just supply a UInt16 and a Byte.
    My usual boring signature: Nothing

  10. #10
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by TnTinMN View Post
    Interesting logic. Any software that is sold is a scam if a reduced feature version is freely available? By that reasoning, I guess the paid versions of Visual Studio are a scam because a large percentage of their features are offered in the free Express Editions. Also by that analogy, any professional programmer giving free advise on this forum is a scammer because they may also charge for their services.
    LOOOOOL. Nooo, I just mean it looks too good to be true from my perspective. I don't see how you can convert vb.net code to C++ using a program. Wouldn't that be basically AI? Or am I over thinking this.

  11. #11
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    677

    Re: C++ to VB.NET conversion.

    Quote Originally Posted by Toph View Post
    LOOOOOL. Nooo, I just mean it looks too good to be true from my perspective. I don't see how you can convert vb.net code to C++ using a program. Wouldn't that be basically AI? Or am I over thinking this.
    (Disclaimer: I work for a company which makes converters, including the one mentioned earlier).

    You're correct - it can't be done 100%.
    However, programming languages have a lot in common regarding syntax - often it looks very different but the underlying intent is the same and the syntax that both languages have in common can be fairly reliably converted to the other language. The syntax that's not common (such as bit fields), well that can be a problem - the converter won't help you there and you'll have to work around those issues yourself.

    Converters can eliminate a lot of manual labor - this is what some people find is worth paying for. How much of your time do you have to save to cover the cost of a converter? If the price is too high, most companies (including ours) offer free versions with some limitations (some of our best feedback has come from people who never paid us a dime).
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

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