HIBYTE Macro

Public Function HIBYTE(ByVal wValue As Integer) As Byte
	HIBYTE = Val("&H" & Left(Right("0000" & Hex(wValue), 4), 2))
End Function

Description & Usage

HIBYTE extracts the high-order byte of a 16-bit integer (a word).

Return Value

The macro returns the high-order byte of the value passed to it.

Visual Basic-Specific Issues

Although it may seem unusual to use string operations for what would otherwise be a mathematical computation, it is necessary to implement HIBYTE this way in VB. Other methods to perform this task can fail for large inputs because VB interprets them as negative values, which causes an equivalent mathematical computation to return an unwanted value.

Parameters

wValue
The 16-bit integer to extract the high-order byte of.

See Also

LOBYTE, MAKEWORD

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


Last Modified: October 29, 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/h/hibyte.html