Results 1 to 2 of 2

Thread: convert long to dword to bytes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Location
    california
    Posts
    245

    convert long to dword to bytes

    Hello,

    lets say I have a long: 345,678

    I need VB to convert to a dword: 5464E

    Then convert that to bytes: 4E 46 05

    How?

    Many thanks for any help

    - Jake

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    VB Code:
    1. Private Type Byte4
    2.     B1 As Byte
    3.     B2 As Byte
    4.     B3 As Byte
    5.     B4 As Byte
    6. End Type
    7.  
    8. Private Type Lng
    9.     L As Long
    10. End Type
    11.  
    12. Private Sub Form_Load()
    13.     Dim MyLng As Lng, My4Bytes As Byte4
    14.    
    15.     MyLng.L = 345678
    16.     LSet My4Bytes = MyLng
    17.    
    18.     Me.Caption = Hex(My4Bytes.B1) & " " & Hex(My4Bytes.B2) & " " & Hex(My4Bytes.B3) & " " & Hex(My4Bytes.B4)
    19. End Sub

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