Results 1 to 7 of 7

Thread: Help me convert this, its easy!!

  1. #1

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Help me convert this, its easy!!

    hello all, I need to convert this code to VB6, could anybody please help me!

    its this function:
    Code:
    #define BITS_PER_CHAR  8
    unsigned short updcrc (unsigned short ch, unsigned short crc)
    {
              register short counter = BITS_PER_CHAR;
              register short temp = crc
              while (--counter >= 0)
                 if (temp & 0x8000){
              temp <<= 1;
              temp += (((ch <<= 1) & 0x0100) != 0);
              temp ^= 0x1021;
                 }
               else{
              temp <<= 1;
              temp += (((ch <<= 1) & 0x0100) != 0);
                 }
    return (temp);
    that calls this one:

    Code:
    #define BITS_PER_CHAR  8
    unsigned short updcrc (unsigned short ch, unsigned short crc)
    {
              register short counter = BITS_PER_CHAR;
              register short temp = crc
              while (--counter >= 0)
                 if (temp & 0x8000){
              temp <<= 1;
              temp += (((ch <<= 1) & 0x0100) != 0);
              temp ^= 0x1021;
                 }
               else{
              temp <<= 1;
              temp += (((ch <<= 1) & 0x0100) != 0);
                 }
    return (temp);

  2. #2
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    convert its easy

    Thats not easy I know some vb and i wouldnt know where to start. VB doesnt give u low level access to register variables or addresses. Thats why its harder than u think and VB sucks.

  3. #3
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Perhaps if you described what they are doing people will be able to come up with a solution.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Its the crc check of smart tags for a SmartPass system. I dont think VB is going to let you do this. You are better off making this a DLL and linking it into your VB program.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    There's no problem doing this in VB, VB has bitwise AND, OR, XOR, and you can simulate bitshifting using multiplication or division. I'm feeling under the weather this morning, if this isn't resolved I'll do some code later.
    an ending

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's possible, but CRC checks are supposed to be very fast, and that's something VB isn't good at, esp. if you emulate the shifts.

    The DLL is the best approach.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    Originally posted by SLH
    Perhaps if you described what they are doing people will be able to come up with a solution.
    i think if he could describe what's going on he would be able to convert it to vb himseld

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