Public Function FIRST_IPADDRESS (ByVal ipAddress As Long) As Long
FIRST_IPADDRESS = Val("&H" & Left(Right("00000000" & Hex(ipAddress), 8), 2))
End Function
FIRST_IPADDRESS extracts the first field (field 0) from an IP address packed inside a 32-bit integer. The IP address must be in host byte order.
The macro returns the value of the first field of the IP address.
Although it may seem unusual to use string operations for what would otherwise be a mathematical computation, it is necessary to implement FIRST_IPADDRESS 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.
FOURTH_IPADDRESS, SECOND_IPADDRESS, THIRD_IPADDRESS
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/f/first_ipaddress.html