Saturday, May 26, 2018

MAKELANGID in VBA

I wonder how I can translate 'MAKELANGID' declared in winnt.h into VBA.
MAKELANGID is declared as follows in winnt.h.
#define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))

Here's the answer.
-----------------------------------------

Function MAKELANGID(p As Integer, s As Integer) As Integer
    Dim lngTemp As Long
    lngTemp = (ShortToLong(s) * 1024) And &HFFFF&
    MAKELANGID = (lngTemp + ShortToLong(p)) And &HFFFF&
End Function

Function ShortToLong(ByVal Short As Integer) As Long
    ShortToLong = Short And &HFFFF&
End Function

No comments: