Results 1 to 2 of 2

Thread: C to VB Conversion Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    2

    C to VB Conversion Problem

    I have a bit of C code that I need to convert to VB, but I'm not sure how exactly. If anyone is familiar with both and can help that would be great.

    The bit of C code is
    ...
    ...
    struct {
    short ic_product[5]; /* binary encoded product name */
    short plant_area;
    short alias_flag;
    } pr_send_buf;
    ...
    ...
    ...
    strncpy(pr_send_buf.ic_product, ac_pc, 10); /* ac_pc would equate to a Product Code of some sort */



    Does anyone have any idea of how to write the same thing in VB?

    Thanks in advance,
    Kevin

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586

    Re: C to VB Conversion Problem

    Hmm it's been a while since I worked with anything in C.

    But I'm thinking you can do something like this

    Code:
    Type varTypeName
         ic_product(5) As Integer 'binary encoded product name
         plant_area As Integer
         alias_flag As Integer
    End Type
    
    Dim pr_send_buf As varTypeName
    Then this is the part I'm not sure what your trying to accomplish..

    strncpy(pr_send_buf.ic_product, ac_pc, 10); /* ac_pc would equate to a Product Code of some sort */

    I know that it just copies the first 10 characters of pr_send_buf.ic_product to ac_pc... but that's an array... none the less in VB to copy a certian amount you could

    Code:
    ac_pc = Left(pr_send_buf.ic_product(1), 10)
    The problem is your gonna have to specify the array position and I'm not sure how that is working for you there.

    Maybe I'm just looking at it wrong and it's not suppose to be an array .. if not someone else would have to help you with that part

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