Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Often, especially when dealing with the Windows AP...
Author:
Merrion Computing
E-mail:
Click to e-mail author
Website:
http://www.merrioncomputing.com
Submitted:
4/27/2001
Version:
VB4
Compatibility:
VB4, VB5, VB6
Category:
Miscellaneous
Views:
5750
Often, especially when dealing with the Windows API, byte and integer variables will be packed into a LONG (32 bit) value. These functions allow you to encode/decode these long values.
Declarations:
'none
Code:
Public Function hiByte(ByVal w As Integer) As Byte If w And &H8000 Then hiByte = &H80 Or ((w And &H7FFF) \ &HFF) Else hiByte = w \ 256 End If End Function Public Function HiWord(dw As Long) As Integer If dw And &H80000000 Then HiWord = (dw \ 65535) - 1 Else HiWord = dw \ 65535 End If End Function Public Function LoByte(w As Integer) As Byte LoByte = w And &HFF End Function Public Function LoWord(dw As Long) As Integer If dw And &H8000& Then LoWord = &H8000 Or (dw And &H7FFF&) Else LoWord = dw And &HFFFF& End If End Function Public Function MakeInt(ByVal LoByte As Byte, ByVal hiByte As Byte) As Integer MakeInt = ((hiByte * &H100) + LoByte) End Function Public Function MakeLong(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long MakeLong = ((HiWord * &H10000) + LoWord) End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2023 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement