bobf22
asked on
SHARED ARRAYS IN VB
I'm converting from VAX BASIC to VB. Is there a way similar to VMS's Named COMMON or C's UNION statement where I can have several arrays start at the same address in memory? The application is a realtime structure which uses a linked list of values; some are bytes, some are integers, some long integers.
Byte BArray (2047,31) ' 32 bytes
Word IArray (2047,15) ! 32 bytes
Long LArray (2047,7) ! 32 bytes
I would like to see these arrays overlay each other by starting at the same physical memory address.
Thanks in Advance,
Bob Fidelman
Byte BArray (2047,31) ' 32 bytes
Word IArray (2047,15) ! 32 bytes
Long LArray (2047,7) ! 32 bytes
I would like to see these arrays overlay each other by starting at the same physical memory address.
Thanks in Advance,
Bob Fidelman
Yes, LSet works okay for what you want to do. For other things (like converting Single floats to Longs) is easy with the MoveMemory API.
-- in module --
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
-- in form / module --
Public Function AsciiFloat(S As String) As Single
Dim L As Long
Dim F As Single
L = AsciiLong(S)
MoveMemory F, L, 4
AsciiFloat = F
End Function
-- in module --
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
-- in form / module --
Public Function AsciiFloat(S As String) As Single
Dim L As Long
Dim F As Single
L = AsciiLong(S)
MoveMemory F, L, 4
AsciiFloat = F
End Function
Helas VB does not have a UNION like structure
Don't know how to do it but maybe u can use the win32 memory mapped file functions in VB using global namespace(like mapped common block in Vax/VMS)to share data between applications.
Read the book "VB Progr. Guide to the Win32 API" -by Dan Appleman.
There're examples elaborated in that book.
I hope this help u
Read the book "VB Progr. Guide to the Win32 API" -by Dan Appleman.
There're examples elaborated in that book.
I hope this help u
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is great... it gives me a head start on the array and pointers. excellent answer.
Hope this helps