LOWORD Macro

Public Function LOWORD (ByVal dwValue As Long) As Long
	Dim hexstr As String
	hexstr = Right("00000000" & Hex(dwValue), 8)
	LOWORD = CLng("&H" & Right(hexstr, 4))
End Function

Description & Usage

The LOWORD macro isolates the low-order word from a 32-bit integer.

Return Value

The macro returns the low-order word of the 32-bit integer passed to it.

Visual Basic-Specific Issues

The method I present for extracting the low-order word may seem unusual, since I first convert the value into an 8-digit hex string and then cut that in half. I do this because it is the only way that works 100% of the time in Visual Basic. All the math-based routines I've seen to do this fail when the &H80000000 bit of dwValue is set, because VB then sees it as a negative number.

Parameters

dwValue
The 32-bit integer to extract the low-order word from.

See Also

HIWORD

Back to the Macro list.
Back to the Reference section.


Last Modified: July 30, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/loword.html