Coding for this main forum question
https://eileenslounge.com/viewtopic....324964#p324964
https://eileenslounge.com/viewtopic....324975#p324975
Code:Option Explicit ' Destination Points to the starting address of the copied block’s destination. Source Points to the starting address of the block of memory to copy Length Specifies the size, in bytes, of the block of memory to copy. #If VBA7 Then Private Declare PtrSafe Sub VBGetTarget Lib "kernel32" Alias "RtlMoveMemory" (Target As Any, ByVal lPointer As LongPtr, ByVal cbCopy As LongPtr) #Else Private Declare Sub VBGetTarget Lib "kernel32" Alias "RtlMoveMemory" (Target As Any, ByVal lPointer As Long, ByVal cbCopy As Long) #End If Sub LongType() ' https://www.excelfox.com/forum/showthread.php/2404-Notes-tests-ByVal-ByRef-Application-Run-OnTime-Multiple-Variable-Arguments-ByRef-ByVal?p=11888&viewfull=1#post11888 https://www.excelfox.com/forum/showthread.php/2404-Notes-tests-ByVal-ByRef-Application-Run-OnTime-Multiple-Variable-Arguments-ByRef-ByVal/page4 https://www.excelfox.com/forum/showthread.php/2824-Tests-Copying-Pasting-API-Cliipboard-issues-and-Rough-notes-on-Advanced-API-stuff?p=17881&viewfull=1#post17881 Dim LngDest As Long, LngSource As Long Rem 1 Biggest long number ' 1a) Let LngSource = 1073741824 + 1073741823 ' =2147483647 1073741824 is 2^30 which is the last but 1 (31th counting from the right), of 32 bits in the 32 Bit binary representation of a number 1073741823 is the resulting decimal you get if you have a 1 in the first 30, counting from the right, of a binary number decimal 2147483647 is in binary 31 digits 1111111111111111111111111111111 VBGetTarget LngDest, VarPtr(LngSource), 4 ' Anything less than 4 will give the wrong number Debug.Print LngDest ' 2147483647 (31 digits 1111111111111111111111111111111) Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 3 Debug.Print LngDest ' 16777215 (24 digits 111111111111111111111111) Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 2 Debug.Print LngDest ' 65535 (16 digits 1111111111111111) Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 1 Debug.Print LngDest ' 255 (8 digits 11111111) Rem 2 Small long number Let LngSource = 2 Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 4 Debug.Print LngDest ' 2 Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 3 Debug.Print LngDest ' 2 Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 2 Debug.Print LngDest ' 2 Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 1 Debug.Print LngDest ' 2 Rem 3 Number decimal 511 (9 digits 111111111) Let LngSource = 511 Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 2 Debug.Print LngDest ' 511 (9 digits 111111111) Let LngDest = 0 VBGetTarget LngDest, VarPtr(LngSource), 1 Debug.Print LngDest ' 255 (8 digits 11111111) Let LngDest = 0 ' LngSource = 511 -> (9 digits 111111111) VBGetTarget LngDest, VarPtr(LngSource) + 1, 1 Debug.Print LngDest ' 1 ( 00000001 ) End Sub
Share ‘kernel32.dll’ https://app.box.com/s/124tsibbnl7pk1xz7assmzivuyyfplo3
Share ‘rpiAPI.dll’ https://app.box.com/s/xfng1rft9mawgcpxlu5z64pps2sg7grv




Reply With Quote
Bookmarks