Results 1 to 6 of 6
  1. #1
    ballybeg is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Canberra Australia
    Posts
    6

    Question Convert large number to Binary for use in TCPIP socket project

    Hey all,

    I am working on a project that requires data transfer using TCPIP sockets. I am using a 3rd party Library (Ostrosoft) that handles the wsock32.dll api calls.

    The project calls for the creation of a header that logs into a user account.

    The first part of the header is a marker, with a value of 4,275,878,552. It is to be supplied in a Binary format of length 4.



    My quesion is "How do I create this marker".

    What I have tried so far is a string variable - strMarker thus:

    strMarker = ChrB(&HFE) & ChrB(&HDC) & ChrB(&HBA) & ChrB(&H98)

    Using the ChrB function to convert the Hex version of that number (FEDCBA98)

    Any clues greatly appreciated.

    ballybeg

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ballybeg is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Canberra Australia
    Posts
    6
    Thanks, It will help if it is not possible to do it in VBA, I will move to vb.net.

    To provide a bit more data, here is the header with values I need to create:


    Name Length Format Value
    Marker 4 Binary 4,275,878,552
    MSN 2 Binary 0
    Message Type 2 Binary 4096
    Message Length 2 Binary 54
    Action Code 2 Binary 4096
    Error Code 2 Binary 0


    In hex the result looks like this:

    Header HEX
    Start marker <4275878552> FE DC BA 98
    MSN <0> 00 00
    Message type <4096> 10 00
    Message length <54> 00 36
    Action code <4096> 10 00
    Error code <0> 00 00

    The final complication is message has to be submitted in network byte order!

    Thanks
    ballybeg



    Perhaps this is too big a task for VBA to handle?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Might be the number is just too large - beyond range of +/- 2147483648. http://windowssecrets.com/forums/showthread.php/49977-Convert-number-to-from-binary-(VBA)

    I didn't notice link was .Net code but I expect could be modified for VBA syntax. The logic should be same.

    This is a bit beyond my experience. What is "Binary format of length 4"?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ballybeg is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Canberra Australia
    Posts
    6
    You are correct in that the number is too large for a long in VBA.

    The binary format length of 4 is four bytes which for the number 4275878552 = FE DC BA 98.

    I know (via calculator) that 4275878522 = 11111110110111001011101010011000 binary, but I need to send the four bytes, so I have been using:

    strMarker = ChrB(&HFE) & ChrB(&HDC) & ChrB(&HBA) & ChrB(&H98)

    Which I figured should work, converting the four hex values to bytes, however I have not had much joy trying to create a login message.

    thanks for the help anyway.

    ballybeg

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This seemed relevant to your issue http://office.microsoft.com/en-us/ac...080764612.aspx

    so I tried:

    ChrB(&HFE) + ChrB(0) & ChrB(&HDC)+ ChrB(0) & ChrB(&HBA) + ChrB(0) & ChrB(&H98)+ ChrB(0)

    the result is: şÜº?

    Without the + ChrB(0) in each part I get: ??

    and with:

    Chr(&HFE) & Chr(&HDC) & Chr(&HBA) & Chr(&H98)

    result is: şÜº˜
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. convert number to text number like in cheque
    By ravideep in forum Reports
    Replies: 1
    Last Post: 03-12-2013, 05:55 AM
  2. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  3. Replies: 2
    Last Post: 11-22-2011, 11:45 AM
  4. How do I convert an incoming object to binary?
    By techneophyte in forum Programming
    Replies: 1
    Last Post: 07-28-2010, 10:42 AM
  5. Access Novice Taking On Large Project - Need Guidance
    By gtangjr in forum Database Design
    Replies: 1
    Last Post: 04-04-2008, 08:41 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
  •  
Other Forums: Microsoft Office Forums