Results 1 to 5 of 5

Thread: c to vb convertion

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    c to vb convertion

    need help in converting code from c to vb6

    c code

    unsigned char tabla1[] = {
    0xB1, 0xB1, 0x73, 0x73, 0xE6, 0xE6,
    0x5A, 0x5A, 0xAB, 0xAB, 0x47, 0x47,
    0x8E, 0x8E, 0x0D, 0x0D, 0x1A, 0x1A,
    0x34, 0x34, 0x68, 0x68, 0x0B, 0x0B
    };

    unsigned char tabla2[] = {
    0x34, 0x62, 0x58, 0x92, 0x76, 0x13,
    0x25, 0x97, 0x56, 0x28, 0x68, 0x13
    };
    then i convert into vb6

    VB Code:
    1. Dim table1 As Variant
    2. Dim table2 As Variant
    3.  
    4. table1 = Array(&HB1, &HB1, &H73, &H73, &HE6, &HE6, _
    5.     &H5A, &H5A, &HAB, &HAB, &H47, &H47, _
    6.     &H8E, &H8E, &HD, &HD, &H1A, &H1A, _
    7.     &H34, &H34, &H68, &H68, &HB, &HB)
    8.    
    9. table2 = Array(&H34, &H62, &H58, &H92, &H76, &H13, _
    10.     &H25, &H97, &H56, &H28, &H68, &H13)

    how about this?

    unsigned short gethalf(unsigned char *donde)
    {
    return ((donde[1]<<8)|donde[0]);
    }

    void sethalf(unsigned char *donde, unsigned short que)
    {
    donde[0] = que & 0xFF;
    donde[1] = (que>>8) & 0xFF;
    }

    void inv(unsigned char *cadena)
    {
    int i;
    unsigned char temp;

    for(i=0; i<=10; i+=2)
    {
    temp = cadena[i];
    cadena[i] = cadena[i+1];
    cadena[i+1] = temp;
    }
    }

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: c to vb convertion

    I'm just writing this as I go, so it will probably have a few Bugs in it.
    VB Code:
    1. Public Function gethalf(donde As String) As Integer
    2. gethalf = Chr(Asc(Mid(donde, 2, 1)) * (2 ^ 8) Or Mid(donde, 1, 1))
    3. End Function
    4.  
    5. Public Function sethalf(donde As String, que As Integer)
    6. Mid(donde, 1, 1) = que And &HFF
    7. Mid(donde, 2, 1) = (que / (2 ^ 8)) And &HFF
    8. End Function
    9.  
    10. Public Function inv(cadena As String)
    11. Dim i As Integer
    12. Dim temp As String
    13.  
    14. For i = 0 To 10 Step 2
    15.     temp = Mid(cadena, i, 1)
    16.     Mid(candena, i, 1) = Mid(cadena, i + 1, 1)
    17.     Mid(cadena, i + 1, 1) = temp
    18. Next
    19. End Function

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: c to vb convertion

    cool

    how about this? mix with assembly? i need only some idea so i can do it my self. thanks

    unsigned int calculo4a(unsigned int param0)
    {
    unsigned int r0, r1, r2;
    int i;

    r1 = unk;
    r0 = param0 << 0x10;
    r2 = r0 >> 0x10;

    for(i=0; i<=0xf; i++)
    {
    r1 = r1 << 1;
    r0 = r2;
    r0 &= 1;
    r1 |= r0;
    r2 = r2 >> 1;
    }

    r0 = r1;

    return r0;
    }

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: c to vb convertion

    It's a function that returns unsigned int... i think that it can be done with Abs() in VB:
    VB Code:
    1. Private Function calculo4a (param0 As Integer) As Integer
    2.     Dim r0 As Integer, r1 As Integer, r2 As Integer
    3.     Dim i As Integer
    4.  
    5.     '...
    6.  
    7.     For i = 0 To 0xf Step 1
    8.         r1 = '...
    9.     Next i
    10.  
    11.     '...
    12.  
    13.     calculo4a = r0
    14. End Function

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: c to vb convertion

    by the way, gavio what the comment '... about? also here r1 = '...

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