SBendBuckeye
Programmer
Hello,
I am primarily a VB programmer, not an API guy although I have worked with the APIs some. If the answer to this is so obvious it is either trivial or ridiculously impossible, please enjoy a chuckle or belly laugh at my expense! So here we go...
One of the things that bugs me about VB is that I cannot return or set an entire row of a given 2 dimensional array.
I was thinking about this the other night when I couldn't sleep and it occurred to me that if an array is (I think) a contiguous block of memory, then I should be able to map it using offset logic. But I don't work at that level so I don't know about how the memory is laid out.
To simplify things, let's say I have a 4 by 8 array named aMatrix with the following long integer data in it:
Row1: 1 10 100 1000
Row2: 2 20 200 2000
Row3: 3 30 300 3000
Row4: 4 40 400 4000
Row5: 5 50 500 5000
Row6: 6 60 600 6000
Row7: 7 70 700 7000
Row8: 8 80 800 8000
Let's also say I have a 4 by 1 array named aRow with the following long integer data in it:
Row1: 0 0 0 0
Now if arrays are just memory offsets, it seems like I should be able to do something like the following:
1. Calculate aMatrix Row5's beginning point in memory
2. Calculate aMatrix Row Length (Length of Long * 4)
3. Copy memory block offset from aMatrix calculated in 1
and 2 above into array aRow so that after the operation
aRow would contain 5 50 500 5000
4. It seems as if 3 should work because both blocks of
memory are the same length (eg Length of Long * 4)
5. If this is doable, does aRow need to be initialized or
just dimensioned to match an aMatrix row
If the above is doable, can it be generalized even further into this scenario...
Let's use array aMatrix as above. Now let's define a User Defined Type as below:
Type UDT
lng1 As Long
lng2 As Long
lng3 As Long
lng4 As Long
End Type
aUTD(7) As UDT
Again, if arrays and user defined types are contiguous blocks of memory, could I do something like this:
1. Calculate aMatrix beginning point in memory
2. Calculate aMatrix Length (Length of Long * 4 * Rows)
3. Copy memory block offset from aMatrix calculated in 1
and 2 above into array aUDT
4. It seems as if 3 should work because both blocks of
memory are the same length (eg Length of Long * 4 * Rows)
5. If this is doable, does aUDT need to be initialized or
just dimensioned to match aMatrix
Now the last set of questions (I aplogize for the long windedness of this all).
1. If either of the above is doable, how would I handle variants or strings, either of which can be variable in length? Or would I need to handle them individually?
Am I even in the ballpark with these concepts? If so, can I do it with APIs? If so, can someone point me? I've already downloaded the API guide from and dug around in it so I'm willing to learn. Thanks to everyone who took the time to wade through the above and for any ideas and/or suggestions!
Have a great day!
j2consulting@yahoo.com
I am primarily a VB programmer, not an API guy although I have worked with the APIs some. If the answer to this is so obvious it is either trivial or ridiculously impossible, please enjoy a chuckle or belly laugh at my expense! So here we go...
One of the things that bugs me about VB is that I cannot return or set an entire row of a given 2 dimensional array.
I was thinking about this the other night when I couldn't sleep and it occurred to me that if an array is (I think) a contiguous block of memory, then I should be able to map it using offset logic. But I don't work at that level so I don't know about how the memory is laid out.
To simplify things, let's say I have a 4 by 8 array named aMatrix with the following long integer data in it:
Row1: 1 10 100 1000
Row2: 2 20 200 2000
Row3: 3 30 300 3000
Row4: 4 40 400 4000
Row5: 5 50 500 5000
Row6: 6 60 600 6000
Row7: 7 70 700 7000
Row8: 8 80 800 8000
Let's also say I have a 4 by 1 array named aRow with the following long integer data in it:
Row1: 0 0 0 0
Now if arrays are just memory offsets, it seems like I should be able to do something like the following:
1. Calculate aMatrix Row5's beginning point in memory
2. Calculate aMatrix Row Length (Length of Long * 4)
3. Copy memory block offset from aMatrix calculated in 1
and 2 above into array aRow so that after the operation
aRow would contain 5 50 500 5000
4. It seems as if 3 should work because both blocks of
memory are the same length (eg Length of Long * 4)
5. If this is doable, does aRow need to be initialized or
just dimensioned to match an aMatrix row
If the above is doable, can it be generalized even further into this scenario...
Let's use array aMatrix as above. Now let's define a User Defined Type as below:
Type UDT
lng1 As Long
lng2 As Long
lng3 As Long
lng4 As Long
End Type
aUTD(7) As UDT
Again, if arrays and user defined types are contiguous blocks of memory, could I do something like this:
1. Calculate aMatrix beginning point in memory
2. Calculate aMatrix Length (Length of Long * 4 * Rows)
3. Copy memory block offset from aMatrix calculated in 1
and 2 above into array aUDT
4. It seems as if 3 should work because both blocks of
memory are the same length (eg Length of Long * 4 * Rows)
5. If this is doable, does aUDT need to be initialized or
just dimensioned to match aMatrix
Now the last set of questions (I aplogize for the long windedness of this all).
1. If either of the above is doable, how would I handle variants or strings, either of which can be variable in length? Or would I need to handle them individually?
Am I even in the ballpark with these concepts? If so, can I do it with APIs? If so, can someone point me? I've already downloaded the API guide from and dug around in it so I'm willing to learn. Thanks to everyone who took the time to wade through the above and for any ideas and/or suggestions!
Have a great day!
j2consulting@yahoo.com