Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Framework  »  HiWord and LoWord operators
HiWord and LoWord operators
by Steven Sartain | Published  10/15/2001 | .NET Framework | Rating:
Steven Sartain

Steven Sartain is a consultant currently designing and leading a VB.NET project using n-tier architecture and WebServices for Accuride International Ltd.

During his 8 year career as a developer and development lead, Steve has designed and implemented a diverse number of mission critical software solutions using VB, VBA, MS Access, C/C++, ASP, Delphi, DCOM & MTS, SQL Server, Oracle, SQL Anywhere and others. See his Resume for details.

He is also a Director of Iridium Software - a UK based bespoke software development house.

Steve is always open to take over a challenging programming opportunity. If you experience a need for a professional consultant who has all the necessary skills to take a proposition from first client meeting through to profitably and elegantly completed projects; I'm sure Steve could assist. See his Resume and Professional Statement for details.


View all articles by Steven Sartain...
HiWord and LoWord operators

Sometimes getting values back from API calls return HiWord and LoWord operators which are used to pack two integers into a long value.

This simple function helps translate your values. The code also demonstrates overriding of a function to accept either an IntPtr or an Int32.

Start a new project then add a module. Add the following code to the module:

'Author: Steven Sartain
'Last Revision: 28th August 2001
'Revision Notes: None
'Supported environments:
'                    Yes        No        Untested
'    VB4              X
'    VB5              X
'    VB6              X
'    VB.NET(beta2)    X
Namespace vbCity
  Namespace API
    Public Module API
      Public Function GetLowWord(ByRef pintValue As Int32As Int32
        Return pintValue And &HFFFF
      End Function
      Public Function GetLowWord(ByRef pudtValue As IntPtrAs Int32
        Return GetLowWord(pudtValue.ToInt32)
      End Function
      Public Function GetHighWord(ByRef pintValue As Int32As Int32
        If (pintValue And &H80000000= &H80000000 Then
          Return ((pintValue And &H7FFF0000\ &H10000Or &H8000&
          Return (pintValue And &HFFFF0000\ &H10000
        End If
      End Function
    End Module
  End Namespace
End Namespace
Generated using PrettyCode.Encoder
How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:3.5 out of 5
 22 people have rated this page
Article Score18914
Sponsored Links