Results 1 to 4 of 4

Thread: Winsock Hexadecimal Data

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    38

    Winsock Hexadecimal Data

    I need to send the Following Data.. This is the HEX of the Data I am going to send.

    Code:
    16 00 00 01 XX XX XX XX
    I am using the Following Code.

    Winsock.Sendata chr(22) & chr(0) & chr(0) & chr(1)

    The last 4 bytes should be filled with timeGetTime of my PC. Its a 4 byte value, so i need to send the value in hex bytes.

    How do I write the timeGetTime in Hex format and send it via Winsock?

    I cant use chr(timeGetTime). Is there any other Function that accepts 4 byte value?

    Edit.. I used this Code. It there a better way of doing it? Especially for large numbers
    Hex_Temp Code:
    1. Dim Hex_Temp As String
    2. Dim Str As String
    3. Dim Tm As Double
    4. Tm = timeGetTime
    5. Hex_Temp = Hex(Tm)
    6. For k = 1 To 8 - Len(Hex_Temp)
    7. Hex_Temp = "0" & Hex_Temp
    8. Next k
    9. Str = Chr(Val("&H" & Mid(Hex_Temp, 7, 2)))
    10. Str = Str & Chr(Val("&H" & Mid(Hex_Temp, 5, 2)))
    11. Str = Str & Chr(Val("&H" & Mid(Hex_Temp, 3, 2)))
    12. Str = Str & Chr(Val("&H" & Mid(Hex_Temp, 1, 2)))
    Last edited by iProgrammer; Sep 13th, 2009 at 12:23 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
  •  



Click Here to Expand Forum to Full Width