Is it possible in Visual Basic 6 to make some variable to reference to another variable, so when one changes, so does the other?
I know it is possible to use Set operator for objects. But how to make this work for integer type variables? The only way I am aware of is to wrap the variable inside an object.
Not through the language itself. You could use a class as you mentioned, the other way is to use the Win32 API.
Specifically
HeapAlloc to allocate memory. You will store the returned address in a Long variable.
Then use RTLMoveMemory renamed as CopyMemory to transfer data in and out of the allocated memory.
Public Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (Destination As Any, Source As Any, _
ByVal Length As Long)
This website has a more complete example of using pointers in VB6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With